@lacrous/omnicloud 0.2.23 → 0.2.25

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lacrous/omnicloud",
3
- "version": "0.2.23",
3
+ "version": "0.2.25",
4
4
  "description": "SDK and core building blocks for OmniCloud — self-hosted cloud storage powered by your Telegram account.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -48,9 +48,9 @@
48
48
  "prisma": "^6.2.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@omnicloud/core": "0.2.23",
52
- "@omnicloud/shared": "0.2.23",
53
- "@omnicloud/telegram": "0.2.23",
51
+ "@omnicloud/core": "0.2.25",
52
+ "@omnicloud/shared": "0.2.25",
53
+ "@omnicloud/telegram": "0.2.25",
54
54
  "@types/node": "^22.10.0",
55
55
  "esbuild": "0.25.12",
56
56
  "tsup": "^8.3.0",
package/server/index.js CHANGED
@@ -1093,6 +1093,13 @@ function uploadRequestFingerprint(input) {
1093
1093
  }
1094
1094
 
1095
1095
  // ../core/src/services/file-service.ts
1096
+ function connectionCausedFailure(error) {
1097
+ if (error instanceof TelegramConnectionError) return true;
1098
+ if (error instanceof UploadFailedError) {
1099
+ return error.details instanceof TelegramConnectionError;
1100
+ }
1101
+ return false;
1102
+ }
1096
1103
  var FileService = class {
1097
1104
  constructor(files, folders, engineFor, activity = noopActivityRecorder, operations = null, log = null) {
1098
1105
  this.files = files;
@@ -1163,8 +1170,9 @@ var FileService = class {
1163
1170
  await operations.update(op.id, { status: "COMPLETED", fileId: record.id });
1164
1171
  return record;
1165
1172
  } catch (error) {
1173
+ const status = connectionCausedFailure(error) ? "UNKNOWN" : "FAILED";
1166
1174
  await operations.update(op.id, {
1167
- status: "FAILED",
1175
+ status,
1168
1176
  error: error instanceof Error ? error.message.slice(0, 200) : "upload failed"
1169
1177
  });
1170
1178
  throw error;
@@ -1799,14 +1807,11 @@ var FolderService = class {
1799
1807
  );
1800
1808
  const restorableFileIds = restorableFiles.map((file) => file.id);
1801
1809
  if (restorableFolders.length > 0) {
1802
- await this.folders.updateMany(
1810
+ await this.folders.restoreSubtree(
1803
1811
  restorableFolders.map((folder) => folder.id),
1804
- { deletedAt: null, trashBatchId: null }
1812
+ restorableFileIds,
1813
+ { rootId: id, reparent: { parentId } }
1805
1814
  );
1806
- await this.folders.update(id, { parentId });
1807
- }
1808
- if (restorableFileIds.length > 0) {
1809
- await this.files.updateMany(restorableFileIds, { deletedAt: null, trashBatchId: null });
1810
1815
  }
1811
1816
  await this.activity.record({
1812
1817
  userId,
@@ -3798,6 +3803,28 @@ function createFolderRepo(prisma) {
3798
3803
  });
3799
3804
  return mapFolder(folder);
3800
3805
  },
3806
+ async restoreSubtree(folderIds, fileIds, options) {
3807
+ await prisma.$transaction(async (tx) => {
3808
+ if (folderIds.length > 0) {
3809
+ await tx.folder.updateMany({
3810
+ where: { id: { in: folderIds } },
3811
+ data: { deletedAt: null, trashBatchId: null }
3812
+ });
3813
+ }
3814
+ if (options.reparent) {
3815
+ await tx.folder.update({
3816
+ where: { id: options.rootId },
3817
+ data: { parentId: options.reparent.parentId }
3818
+ });
3819
+ }
3820
+ if (fileIds.length > 0) {
3821
+ await tx.file.updateMany({
3822
+ where: { id: { in: fileIds } },
3823
+ data: { deletedAt: null, trashBatchId: null }
3824
+ });
3825
+ }
3826
+ });
3827
+ },
3801
3828
  async trashSubtree(folderIds, fileIds, stamp) {
3802
3829
  await prisma.$transaction(async (tx) => {
3803
3830
  if (folderIds.length > 0) {
@@ -5068,7 +5095,7 @@ function encryptionCheck(configured) {
5068
5095
  }
5069
5096
 
5070
5097
  // ../../apps/api/src/routes/storage.ts
5071
- var VERSION = "0.2.23";
5098
+ var VERSION = "0.2.25";
5072
5099
  function registerStorageRoutes(app2, container2) {
5073
5100
  app2.get("/api/health", async () => {
5074
5101
  const database = await probeDatabase(container2);