@adminforth/storage-adapter-local 1.0.9 → 1.0.11
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 +5 -34
- package/index.ts +5 -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) {
|
|
@@ -266,7 +237,7 @@ class AdminForthStorageAdapterLocalFilesystem {
|
|
|
266
237
|
afLogger.error(`Could not write metadata to db: ${e}`);
|
|
267
238
|
throw new Error(`Could not write metadata to db: ${e}`);
|
|
268
239
|
});
|
|
269
|
-
this.
|
|
240
|
+
this.markKeyForDeletion(key);
|
|
270
241
|
res.status(200).send("File uploaded");
|
|
271
242
|
});
|
|
272
243
|
}));
|
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> {
|
|
@@ -297,7 +270,7 @@ export default class AdminForthStorageAdapterLocalFilesystem implements StorageA
|
|
|
297
270
|
throw new Error(`Could not write metadata to db: ${e}`);
|
|
298
271
|
});
|
|
299
272
|
|
|
300
|
-
this.
|
|
273
|
+
this.markKeyForDeletion(key);
|
|
301
274
|
|
|
302
275
|
res.status(200).send("File uploaded");
|
|
303
276
|
});
|