Skip to content

Commit

Permalink
Remove regenerated pipeline files (#572)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Cody Baker <[email protected]>
  • Loading branch information
3 people authored Jan 29, 2024
1 parent 917704e commit b3e2318
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
28 changes: 15 additions & 13 deletions src/renderer/src/progress/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,21 @@ export function resume(name) {
return commandToResume;
}

export const remove = async (name) => {
const result = await Swal.fire({
title: `Are you sure you would like to delete this conversion pipeline?`,
html: `All related files will be deleted permanently, and existing progress will be lost.`,
icon: "warning",
heightAuto: false,
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: `Delete ${name}`,
cancelButtonText: "Cancel",
focusCancel: true,
});
export const remove = async (name, force = false) => {
const result = force
? { isConfirmed: true }
: await Swal.fire({
title: `Are you sure you would like to delete this conversion pipeline?`,
html: `All related files will be deleted permanently, and existing progress will be lost.`,
icon: "warning",
heightAuto: false,
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: `Delete ${name}`,
cancelButtonText: "Cancel",
focusCancel: true,
});

if (result.isConfirmed) return operations.remove(name);

Expand Down
7 changes: 5 additions & 2 deletions src/renderer/src/progress/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ export const remove = (name) => {
const progressFilePathToDelete = joinPath(guidedProgressFilePath, name + ".json");

//delete the progress file
if (fs) fs.unlinkSync(progressFilePathToDelete);
else localStorage.removeItem(progressFilePathToDelete);
if (fs) {
if (fs.existsSync(progressFilePathToDelete)) fs.unlinkSync(progressFilePathToDelete);
} else localStorage.removeItem(progressFilePathToDelete);

if (fs) {
console.log(previewSaveFolderPath, conversionSaveFolderPath, name);

// delete default preview location
fs.rmSync(joinPath(previewSaveFolderPath, name), { recursive: true, force: true });

Expand Down
8 changes: 6 additions & 2 deletions src/renderer/src/stories/pages/settings/SettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import developerGlobalSchema from "../../../../../../schemas/json/developer/glob
import { validateDANDIApiKey } from "../../../validation/dandi";

import { Button } from "../../Button.js";
import { global, save } from "../../../progress/index.js";
import { global, remove, save } from "../../../progress/index.js";
import { merge, setUndefinedIfNotDeclared } from "../utils.js";

import { notyf } from "../../../dependencies/globals.js";
Expand All @@ -34,11 +34,15 @@ function saveNewPipelineFromYaml(name, sourceData, rootFolder) {
});
});

const updatedName = header(name);

remove(updatedName, true);

save({
info: {
globalState: {
project: {
name: header(name),
name: updatedName,
initialized: true,
},

Expand Down

0 comments on commit b3e2318

Please sign in to comment.