Skip to content

Commit 80195fc

Browse files
committed
fix: don't try to delete nonexistent files
1 parent 8fc9cf3 commit 80195fc

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/decap-cms-core/src/backend.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,20 @@ export class Backend {
13291329
await this.invokePreUnpublishEvent(entry);
13301330
let paths = [path];
13311331
if (hasI18n(collection)) {
1332-
paths = getFilePaths(collection, extension, path, slug);
1332+
const allPaths = getFilePaths(collection, extension, path, slug);
1333+
// Filter out non-existent files to prevent deletion errors
1334+
const existingPaths = await Promise.all(
1335+
allPaths.map(async filePath => {
1336+
try {
1337+
await this.implementation.getEntry(filePath);
1338+
return filePath;
1339+
} catch (error) {
1340+
// File doesn't exist, skip it
1341+
return null;
1342+
}
1343+
}),
1344+
);
1345+
paths = existingPaths.filter((p): p is string => p !== null);
13331346
}
13341347
await this.implementation.deleteFiles(paths, commitMessage);
13351348

0 commit comments

Comments
 (0)