@@ -72,7 +72,7 @@ const addLink = (context, options, callback) => {
72
72
return addToShardedDirectory ( context , options , callback )
73
73
}
74
74
75
- if ( options . parent . links . length == = options . shardSplitThreshold ) {
75
+ if ( options . parent . links . length > = options . shardSplitThreshold ) {
76
76
log ( 'Converting directory to sharded directory' )
77
77
78
78
return convertToShardedDirectory ( context , options , callback )
@@ -151,8 +151,21 @@ const addToShardedDirectory = async (context, options, callback) => {
151
151
} )
152
152
}
153
153
154
+ const existingFile = options . parent . links
155
+ . filter ( link => link . name . substring ( 2 ) === options . name )
156
+ . pop ( )
157
+
158
+ if ( existingFile ) {
159
+ log ( `Updating file ${ existingFile . name } ` )
160
+
161
+ return addToDirectory ( context , {
162
+ ...options ,
163
+ name : existingFile . name
164
+ } , callback )
165
+ }
166
+
154
167
const existingUnshardedFile = options . parent . links
155
- . filter ( link => link . name . substring ( 0 , 2 ) === prefix || link . name . substring ( 2 ) === options . name )
168
+ . filter ( link => link . name . substring ( 0 , 2 ) === prefix )
156
169
. pop ( )
157
170
158
171
if ( existingUnshardedFile ) {
@@ -194,7 +207,7 @@ const addToShardedDirectory = async (context, options, callback) => {
194
207
} )
195
208
}
196
209
197
- log ( `Updating or appending ${ prefix + options . name } to shard` )
210
+ log ( `Appending ${ prefix + options . name } to shard` )
198
211
199
212
return addToDirectory ( context , {
200
213
...options ,
0 commit comments