sliftutils 1.7.49 → 1.7.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -98,7 +98,7 @@ export declare const RemoteStorageController: import("socket-function/SocketFunc
98
98
  }[];
99
99
  } | undefined>;
100
100
  getSyncStatus: (account: string, bucketName: string) => Promise<ArchivesSyncStatus>;
101
- startLargeFile: (account: string, bucketName: string, path: string) => Promise<string>;
101
+ startLargeFile: (account: string, bucketName: string, path: string, lastModified?: number) => Promise<string>;
102
102
  uploadPart: (uploadId: string, data: Buffer) => Promise<void>;
103
103
  finishLargeFile: (uploadId: string) => Promise<void>;
104
104
  cancelLargeFile: (uploadId: string) => Promise<void>;
@@ -363,16 +363,16 @@ class RemoteStorageControllerBase {
363
363
  return await bucket.store.getSyncStatus();
364
364
  }
365
365
 
366
- async startLargeFile(account: string, bucketName: string, path: string): Promise<string> {
366
+ async startLargeFile(account: string, bucketName: string, path: string, lastModified?: number): Promise<string> {
367
367
  assertWritesAllowed();
368
368
  assertValidPath(path);
369
369
  let bucket = await getBucket(account, bucketName);
370
370
  if (!bucket) {
371
371
  throw new Error(`Bucket ${account}/${bucketName} does not exist. Write its routing config to ${JSON.stringify(ROUTING_FILE)} to create it.`);
372
372
  }
373
- await assertMutable(bucket, path, Date.now());
373
+ await assertMutable(bucket, path, lastModified || Date.now());
374
374
  let id = await bucket.store.startLargeUpload();
375
- largeUploadInfo.set(id, { account, bucketName, path });
375
+ largeUploadInfo.set(id, { account, bucketName, path, lastModified });
376
376
  return id;
377
377
  }
378
378
  async uploadPart(uploadId: string, data: Buffer): Promise<void> {
@@ -390,7 +390,7 @@ class RemoteStorageControllerBase {
390
390
  largeUploadInfo.delete(uploadId);
391
391
  let bucket = await getBucket(info.account, info.bucketName);
392
392
  if (!bucket) throw new Error(`Bucket ${info.account}/${info.bucketName} no longer exists`);
393
- await bucket.store.finishLargeUpload(uploadId, info.path);
393
+ await bucket.store.finishLargeUpload(uploadId, info.path, info.lastModified);
394
394
  }
395
395
  async cancelLargeFile(uploadId: string): Promise<void> {
396
396
  let info = largeUploadInfo.get(uploadId);
@@ -482,7 +482,7 @@ class RemoteStorageControllerBase {
482
482
  }
483
483
  }
484
484
 
485
- const largeUploadInfo = new Map<string, { account: string; bucketName: string; path: string }>();
485
+ const largeUploadInfo = new Map<string, { account: string; bucketName: string; path: string; lastModified?: number }>();
486
486
 
487
487
  const accountAccess: SocketFunctionHook = async (context) => {
488
488
  let start = Date.now();
@@ -1068,13 +1068,13 @@ class ArchivesLocalBucket implements IArchives {
1068
1068
  public async del(fileName: string): Promise<void> {
1069
1069
  await deleteBucketFile(this.account, this.bucketName, fileName);
1070
1070
  }
1071
- public async setLargeFile(config: { path: string; getNextData(): Promise<Buffer | undefined> }): Promise<void> {
1071
+ public async setLargeFile(config: { path: string; lastModified?: number; getNextData(): Promise<Buffer | undefined> }): Promise<void> {
1072
1072
  assertWritesAllowed();
1073
1073
  let bucket = await this.getBucket();
1074
1074
  if (!bucket) {
1075
1075
  throw new Error(`Bucket ${this.account}/${this.bucketName} does not exist. Write its routing config to ${JSON.stringify(ROUTING_FILE)} to create it.`);
1076
1076
  }
1077
- await assertMutable(bucket, config.path, Date.now());
1077
+ await assertMutable(bucket, config.path, config.lastModified || Date.now());
1078
1078
  let id = await bucket.store.startLargeUpload();
1079
1079
  try {
1080
1080
  while (true) {
@@ -1084,7 +1084,7 @@ class ArchivesLocalBucket implements IArchives {
1084
1084
  await bucket.store.appendLargeUpload(id, data.subarray(offset, offset + LARGE_FILE_PART_SIZE));
1085
1085
  }
1086
1086
  }
1087
- await bucket.store.finishLargeUpload(id, config.path);
1087
+ await bucket.store.finishLargeUpload(id, config.path, config.lastModified);
1088
1088
  } catch (e) {
1089
1089
  await bucket.store.cancelLargeUpload(id);
1090
1090
  throw e;