@@ -91,12 +91,23 @@ export class Storage {
9191 . execute ( )
9292 }
9393
94- async completeUpload ( key : string , version : string , scope : string ) {
94+ async completeUpload ( {
95+ key,
96+ version,
97+ scope,
98+ repoId,
99+ } : {
100+ key : string
101+ version : string
102+ scope : string
103+ repoId : string
104+ } ) {
95105 const upload = await this . db
96106 . selectFrom ( 'uploads' )
97107 . where ( 'key' , '=' , key )
98108 . where ( 'version' , '=' , version )
99109 . where ( 'scope' , '=' , scope )
110+ . where ( 'repoId' , '=' , repoId )
100111 . selectAll ( )
101112 . executeTakeFirst ( )
102113 if ( ! upload ) return
@@ -141,6 +152,7 @@ export class Storage {
141152 . where ( 'key' , '=' , key )
142153 . where ( 'version' , '=' , version )
143154 . where ( 'scope' , '=' , scope )
155+ . where ( 'repoId' , '=' , repoId )
144156 . innerJoin ( 'storage_locations' , 'storage_locations.id' , 'cache_entries.locationId' )
145157 . select ( [ 'cache_entries.id' , 'cache_entries.locationId' , 'storage_locations.folderName' ] )
146158 . executeTakeFirst ( )
@@ -169,6 +181,7 @@ export class Storage {
169181 updatedAt : Date . now ( ) ,
170182 locationId,
171183 scope,
184+ repoId,
172185 } )
173186 . execute ( )
174187
@@ -305,11 +318,23 @@ export class Storage {
305318 }
306319 }
307320
308- async createUpload ( key : string , version : string , scope : string ) {
321+ async createUpload ( {
322+ key,
323+ version,
324+ scope,
325+ repoId,
326+ } : {
327+ key : string
328+ version : string
329+ scope : string
330+ repoId : string
331+ } ) {
309332 const existingUpload = await this . db
310333 . selectFrom ( 'uploads' )
311334 . where ( 'key' , '=' , key )
312335 . where ( 'version' , '=' , version )
336+ . where ( 'scope' , '=' , scope )
337+ . where ( 'repoId' , '=' , repoId )
313338 . select ( 'id' )
314339 . executeTakeFirst ( )
315340 if ( existingUpload ) return
@@ -324,6 +349,7 @@ export class Storage {
324349 key,
325350 version,
326351 scope,
352+ repoId,
327353 lastPartUploadedAt : null ,
328354 finishedPartUploadCount : 0 ,
329355 startedPartUploadCount : 0 ,
@@ -337,17 +363,20 @@ export class Storage {
337363 keys : [ primaryKey , ...restoreKeys ] ,
338364 version,
339365 scopes,
366+ repoId,
340367 } : {
341368 keys : [ string , ...string [ ] ]
342369 version : string
343370 scopes : string [ ]
371+ repoId : string
344372 } ) {
345373 for ( const scope of scopes ) {
346374 const exactPrimaryMatch = await this . db
347375 . selectFrom ( 'cache_entries' )
348376 . where ( 'key' , '=' , primaryKey )
349377 . where ( 'version' , '=' , version )
350378 . where ( 'scope' , '=' , scope )
379+ . where ( 'repoId' , '=' , repoId )
351380 . selectAll ( )
352381 . executeTakeFirst ( )
353382 if ( exactPrimaryMatch )
@@ -361,6 +390,7 @@ export class Storage {
361390 . where ( 'key' , 'like' , `${ primaryKey } %` )
362391 . where ( 'version' , '=' , version )
363392 . where ( 'scope' , '=' , scope )
393+ . where ( 'repoId' , '=' , repoId )
364394 . orderBy ( 'cache_entries.updatedAt' , 'desc' )
365395 . selectAll ( )
366396 . executeTakeFirst ( )
@@ -379,6 +409,7 @@ export class Storage {
379409 . where ( 'key' , '=' , key )
380410 . where ( 'version' , '=' , version )
381411 . where ( 'scope' , '=' , scope )
412+ . where ( 'repoId' , '=' , repoId )
382413 . orderBy ( 'updatedAt' , 'desc' )
383414 . selectAll ( )
384415 . executeTakeFirst ( )
@@ -393,6 +424,7 @@ export class Storage {
393424 . where ( 'key' , 'like' , `${ key } %` )
394425 . where ( 'version' , '=' , version )
395426 . where ( 'scope' , '=' , scope )
427+ . where ( 'repoId' , '=' , repoId )
396428 . orderBy ( 'updatedAt' , 'desc' )
397429 . selectAll ( )
398430 . executeTakeFirst ( )
0 commit comments