@adminforth/storage-adapter-local 1.0.10 → 1.0.12
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/dist/index.js +7 -34
- package/index.ts +8 -32
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -74,43 +74,14 @@ class AdminForthStorageAdapterLocalFilesystem {
|
|
|
74
74
|
}
|
|
75
75
|
markKeyForDeletation(key) {
|
|
76
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
afLogger.
|
|
78
|
-
|
|
79
|
-
afLogger.error(`Could not read metadata from db: ${e}`);
|
|
80
|
-
throw new Error(`Could not read metadata from db: ${e}`);
|
|
81
|
-
});
|
|
82
|
-
if (!metadata) {
|
|
83
|
-
afLogger.error(`Metadata for key ${key} not found`);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const metadataParsed = JSON.parse(metadata);
|
|
87
|
-
try {
|
|
88
|
-
yield this.candidatesForDeletionDb.get(key);
|
|
89
|
-
// if key already exists, do nothing
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
catch (e) {
|
|
93
|
-
// if key does not exist, continue
|
|
94
|
-
}
|
|
95
|
-
try {
|
|
96
|
-
yield this.candidatesForDeletionDb.put(key, metadataParsed.createdAt);
|
|
97
|
-
}
|
|
98
|
-
catch (e) {
|
|
99
|
-
afLogger.error(`Could not write metadata to db: ${e}`);
|
|
100
|
-
throw new Error(`Could not write metadata to db: ${e}`);
|
|
101
|
-
}
|
|
77
|
+
afLogger.warn("Method \"markKeyForDeletation\" is deprecated. Please update upload plugin");
|
|
78
|
+
this.markKeyForDeletion(key);
|
|
102
79
|
});
|
|
103
80
|
}
|
|
104
81
|
markKeyForNotDeletation(key) {
|
|
105
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
afLogger.
|
|
107
|
-
|
|
108
|
-
// if key exists, delete it
|
|
109
|
-
yield this.candidatesForDeletionDb.del(key);
|
|
110
|
-
}
|
|
111
|
-
catch (e) {
|
|
112
|
-
// if key does not exist, do nothing
|
|
113
|
-
}
|
|
83
|
+
afLogger.warn("Method \"markKeyForNotDeletation\" is deprecated. Please update upload plugin");
|
|
84
|
+
this.markKeyForNotDeletion(key);
|
|
114
85
|
});
|
|
115
86
|
}
|
|
116
87
|
markKeyForDeletion(key) {
|
|
@@ -305,7 +276,9 @@ class AdminForthStorageAdapterLocalFilesystem {
|
|
|
305
276
|
}, (err) => {
|
|
306
277
|
if (err) {
|
|
307
278
|
afLogger.error(`Could not send file ${filePath}: ${err}`);
|
|
308
|
-
res.
|
|
279
|
+
if (!res.headersSent) {
|
|
280
|
+
res.status(500).send("Could not send file");
|
|
281
|
+
}
|
|
309
282
|
}
|
|
310
283
|
});
|
|
311
284
|
}));
|
package/index.ts
CHANGED
|
@@ -99,40 +99,13 @@ export default class AdminForthStorageAdapterLocalFilesystem implements StorageA
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
async markKeyForDeletation(key: string): Promise<void> {
|
|
102
|
-
afLogger.
|
|
103
|
-
|
|
104
|
-
afLogger.error(`Could not read metadata from db: ${e}`);
|
|
105
|
-
throw new Error(`Could not read metadata from db: ${e}`);
|
|
106
|
-
});
|
|
107
|
-
if (!metadata) {
|
|
108
|
-
afLogger.error(`Metadata for key ${key} not found`);
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const metadataParsed = JSON.parse(metadata);
|
|
112
|
-
|
|
113
|
-
try {
|
|
114
|
-
await this.candidatesForDeletionDb.get(key);
|
|
115
|
-
// if key already exists, do nothing
|
|
116
|
-
return;
|
|
117
|
-
} catch (e) {
|
|
118
|
-
// if key does not exist, continue
|
|
119
|
-
}
|
|
120
|
-
try {
|
|
121
|
-
await this.candidatesForDeletionDb.put(key, metadataParsed.createdAt)
|
|
122
|
-
} catch (e) {
|
|
123
|
-
afLogger.error(`Could not write metadata to db: ${e}`);
|
|
124
|
-
throw new Error(`Could not write metadata to db: ${e}`);
|
|
125
|
-
}
|
|
102
|
+
afLogger.warn("Method \"markKeyForDeletation\" is deprecated. Please update upload plugin");
|
|
103
|
+
this.markKeyForDeletion(key);
|
|
126
104
|
}
|
|
127
105
|
|
|
128
106
|
async markKeyForNotDeletation(key: string): Promise<void> {
|
|
129
|
-
afLogger.
|
|
130
|
-
|
|
131
|
-
// if key exists, delete it
|
|
132
|
-
await this.candidatesForDeletionDb.del(key);
|
|
133
|
-
} catch (e) {
|
|
134
|
-
// if key does not exist, do nothing
|
|
135
|
-
}
|
|
107
|
+
afLogger.warn("Method \"markKeyForNotDeletation\" is deprecated. Please update upload plugin");
|
|
108
|
+
this.markKeyForNotDeletion(key);
|
|
136
109
|
}
|
|
137
110
|
|
|
138
111
|
async markKeyForDeletion(key: string): Promise<void> {
|
|
@@ -343,7 +316,10 @@ export default class AdminForthStorageAdapterLocalFilesystem implements StorageA
|
|
|
343
316
|
(err) => {
|
|
344
317
|
if (err) {
|
|
345
318
|
afLogger.error(`Could not send file ${filePath}: ${err}`);
|
|
346
|
-
|
|
319
|
+
|
|
320
|
+
if (!res.headersSent) {
|
|
321
|
+
res.status(500).send("Could not send file");
|
|
322
|
+
}
|
|
347
323
|
}
|
|
348
324
|
}
|
|
349
325
|
);
|