Skip to content

Commit 2e1ee72

Browse files
committed
fix: update storage adapter method names for consistency and bump adminforth dependency version
1 parent 7dc94e3 commit 2e1ee72

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

index.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ export default class UploadPlugin extends AdminForthPlugin {
128128
if (record[pathColumnName]) {
129129
process.env.HEAVY_DEBUG && console.log('🪥🪥 remove ObjectTagging', record[pathColumnName]);
130130
// let it crash if it fails: this is a new file which just was uploaded.
131-
await this.options.storageAdapter.markKeyForNotDeletation(record[pathColumnName]);
131+
if (this.options.storageAdapter.markKeyForNotDeletion !== undefined) {
132+
await this.options.storageAdapter.markKeyForNotDeletion(record[pathColumnName]);
133+
} else {
134+
await this.options.storageAdapter.markKeyForNotDeletation(record[pathColumnName]);
135+
}
132136
}
133137
return { ok: true };
134138
});
@@ -171,7 +175,11 @@ export default class UploadPlugin extends AdminForthPlugin {
171175
resourceConfig.hooks.delete.afterSave.push(async ({ record }: { record: any }) => {
172176
if (record[pathColumnName]) {
173177
try {
174-
await this.options.storageAdapter.markKeyForDeletation(record[pathColumnName]);
178+
if (this.options.storageAdapter.markKeyForDeletion !== undefined) {
179+
await this.options.storageAdapter.markKeyForDeletion(record[pathColumnName]);
180+
} else {
181+
await this.options.storageAdapter.markKeyForDeletation(record[pathColumnName]);
182+
}
175183
} catch (e) {
176184
// file might be e.g. already deleted, so we catch error
177185
console.error(`Error setting tag ${ADMINFORTH_NOT_YET_USED_TAG} to true for object ${record[pathColumnName]}. File will not be auto-cleaned up`, e);
@@ -192,7 +200,11 @@ export default class UploadPlugin extends AdminForthPlugin {
192200
if (oldRecord[pathColumnName]) {
193201
// put tag to delete old file
194202
try {
195-
await this.options.storageAdapter.markKeyForDeletation(oldRecord[pathColumnName]);
203+
if (this.options.storageAdapter.markKeyForDeletion !== undefined) {
204+
await this.options.storageAdapter.markKeyForDeletion(oldRecord[pathColumnName]);
205+
} else {
206+
await this.options.storageAdapter.markKeyForDeletation(oldRecord[pathColumnName]);
207+
}
196208
} catch (e) {
197209
// file might be e.g. already deleted, so we catch error
198210
console.error(`Error setting tag ${ADMINFORTH_NOT_YET_USED_TAG} to true for object ${oldRecord[pathColumnName]}. File will not be auto-cleaned up`, e);
@@ -201,8 +213,12 @@ export default class UploadPlugin extends AdminForthPlugin {
201213
if (updates[pathColumnName] !== null) {
202214
// remove tag from new file
203215
// in this case we let it crash if it fails: this is a new file which just was uploaded.
216+
if (this.options.storageAdapter.markKeyForNotDeletion !== undefined) {
217+
await this.options.storageAdapter.markKeyForNotDeletion(updates[pathColumnName]);
218+
} else {
204219
await this.options.storageAdapter.markKeyForNotDeletation(updates[pathColumnName]);
205220
}
221+
}
206222
}
207223
return { ok: true };
208224
});

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"dependencies": {
2323
"@aws-sdk/client-s3": "^3.629.0",
2424
"@aws-sdk/s3-request-presigner": "^3.629.0",
25-
"adminforth": "^2.4.0-next.237"
25+
"adminforth": "^2.4.0-next.315"
2626
},
2727
"keywords": [
2828
"adminforth",

0 commit comments

Comments
 (0)