Failure to write is a failure to update

This commit is contained in:
buzz-lightsnack-2007 2024-06-08 17:45:07 +08:00
parent c6f1249c44
commit fffef232c0

View file

@ -94,16 +94,20 @@ export default class FilterManager {
// Only work when the filter is valid. // Only work when the filter is valid.
if (result) { if (result) {
// Write the filter to storage. // Write the filter to storage.
await global.write(["filters", filter_URL], result, -1, {"silent": true}); if (!(await global.write(["filters", filter_URL], result, -1, {"silent": true}))) {
throw ReferenceError;
};
// Add the filter to the sync list. // Add the filter to the sync list.
if ((await global.read(["settings", `filters`])) ? !((Object.keys(await global.read(["settings", `filters`]))).includes(filter_URL)) : true) { if ((await global.read(["settings", `filters`])) ? !((Object.keys(await global.read(["settings", `filters`]))).includes(filter_URL)) : true) {
global.write(["settings", `filters`, filter_URL], true, 1, {"silent": true}); if (!(global.write(["settings", `filters`, filter_URL], true, 1, {"silent": true}))) {
throw ReferenceError;
};
}; };
// Notify that the update is completed. // Notify that the update is completed.
new logging(texts.localized(`settings_filters_update_status_complete`),filter_URL); new logging(texts.localized(`settings_filters_update_status_complete`),filter_URL);
} };
}) })
.catch((error) => { .catch((error) => {
// Inform the user of the download failure. // Inform the user of the download failure.