Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove regenerated pipeline files #572

Merged
merged 6 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading