fix model del & rename
This commit is contained in:
+3
-2
@@ -611,8 +611,9 @@ function createApp({
|
||||
}
|
||||
if (!records.length) return { success: false, errMsg: "数据库中未找到对应记录" };
|
||||
let deletedCount = 0;
|
||||
for (const record of records) deletedCount += await removeFile(database, record.fileID);
|
||||
return { success: true, deletedFileID: records.map((record) => record.fileID).join(", "), deletedCount };
|
||||
const fileIDs = [...new Set(records.map((record) => record.fileID))];
|
||||
for (const fileID of fileIDs) deletedCount += await removeFile(database, fileID);
|
||||
return { success: true, deletedFileID: fileIDs.join(", "), deletedCount };
|
||||
});
|
||||
}
|
||||
case "publishIdentificationConfig": {
|
||||
|
||||
@@ -244,6 +244,19 @@ test("model upload requires explicit overwrite for an existing file", async () =
|
||||
await fs.promises.readFile(path.join(dataDirectory, "models", "company-a", "overwrite-line", "controller.bin"), "utf8"),
|
||||
"second-version"
|
||||
);
|
||||
|
||||
const deleted = await post({
|
||||
type: "deleteModel", fileID: replacement.fileID, adminToken: "test-token"
|
||||
});
|
||||
assert.equal(deleted.success, true);
|
||||
assert.equal(deleted.deletedCount, 1);
|
||||
const listed = await post({
|
||||
type: "listModels", folder: "company-a/overwrite-line/model_config"
|
||||
});
|
||||
assert.deepEqual(listed.fileList, []);
|
||||
await assert.rejects(fs.promises.access(
|
||||
path.join(dataDirectory, "models", "company-a", "overwrite-line", "controller.bin")
|
||||
), { code: "ENOENT" });
|
||||
});
|
||||
|
||||
test("panel consumes uploaded device files from an inbox without scanning folders", async () => {
|
||||
|
||||
Reference in New Issue
Block a user