add try catch around send2trash, change all nodecafe.org to nodecafe.co
This commit is contained in:
+11
-3
@@ -13,7 +13,10 @@ from .service.media_service import *
|
||||
from .service.file_sync_service import *
|
||||
from .service.db_service import get_my_workflows_dir
|
||||
from .service.node_service import *
|
||||
from send2trash import send2trash
|
||||
try:
|
||||
from send2trash import send2trash
|
||||
except ImportError:
|
||||
send2trash = None
|
||||
|
||||
WEB_DIRECTORY = "entry"
|
||||
NODE_CLASS_MAPPINGS = {}
|
||||
@@ -120,8 +123,13 @@ async def delete_file(request):
|
||||
full_path = os.path.join(my_workflows_dir, file_path)
|
||||
|
||||
if os.path.exists(full_path):
|
||||
send2trash(full_path)
|
||||
"File deleted successfully"
|
||||
if send2trash:
|
||||
send2trash(full_path)
|
||||
else:
|
||||
os.remove(full_path)
|
||||
print("❌⛔️send2trash is not available. Deleting file permanently. Please `pip install send2trash`")
|
||||
|
||||
return "File deleted successfully"
|
||||
else:
|
||||
return "File not found"
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ from .model_manager.model_preview import get_thumbnail_for_image_file
|
||||
|
||||
image_extensions = ['.jpg', '.jpeg', '.png', '.gif', '.webp']
|
||||
video_extensions = ['.mp4', '.mov', '.avi', '.webm', '.mkv']
|
||||
API_URL = 'https://www.nodecafe.org/api/image/upload'
|
||||
API_URL = 'https://www.nodecafe.co/api/image/upload'
|
||||
def view_media(filename, isPreview = False, isInput = False):
|
||||
if not filename:
|
||||
return web.Response(status=404)
|
||||
|
||||
@@ -3,9 +3,12 @@ import shutil
|
||||
from aiohttp import web
|
||||
import os
|
||||
from pathlib import Path
|
||||
from send2trash import send2trash
|
||||
import server
|
||||
from .db_service import get_my_workflows_dir
|
||||
try:
|
||||
from send2trash import send2trash
|
||||
except ImportError:
|
||||
send2trash = None
|
||||
|
||||
@server.PromptServer.instance.routes.post('/workspace/folder/create')
|
||||
async def create_folder(request):
|
||||
@@ -32,7 +35,11 @@ def delete_folder_sync(reqJson):
|
||||
folder_path = reqJson.get('path')
|
||||
folder_path = os.path.join(get_my_workflows_dir(), folder_path)
|
||||
try:
|
||||
send2trash(folder_path)
|
||||
if send2trash:
|
||||
send2trash(folder_path)
|
||||
else:
|
||||
shutil.rmtree(folder_path)
|
||||
print("❌⛔️send2trash is not available. Deleting file permanently. Please `pip install send2trash`")
|
||||
return {"success": True}
|
||||
except Exception as e:
|
||||
return {"success": False, "error": str(e)}
|
||||
|
||||
@@ -43,7 +43,7 @@ export class UserSettingsTable extends TableBase<UserSettings> {
|
||||
autoSaveDuration: 3,
|
||||
twoWaySync: false,
|
||||
foldersOnTop: false,
|
||||
cloudHost: "https://www.nodecafe.org",
|
||||
cloudHost: "https://www.nodecafe.co",
|
||||
overwriteCurWorkflowWhenDroppingFileToCanvas: false,
|
||||
maximumChangelogNumber: 80,
|
||||
hideCoverImage: false,
|
||||
|
||||
@@ -1,27 +1,29 @@
|
||||
import {
|
||||
Input,
|
||||
Stack,
|
||||
useToast,
|
||||
Text,
|
||||
HStack,
|
||||
Flex,
|
||||
Button,
|
||||
} from "@chakra-ui/react";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { Input, Stack, useToast, Text, Flex, Button } from "@chakra-ui/react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { userSettingsTable } from "../db-tables/WorkspaceDB";
|
||||
|
||||
export default function CloudHostSetting() {
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const toast = useToast();
|
||||
const [text, setText] = useState("");
|
||||
|
||||
const getSettings = () => {
|
||||
userSettingsTable?.getSetting("cloudHost").then((res) => {
|
||||
inputRef.current?.setAttribute("value", res ?? "");
|
||||
setText(res ?? "");
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getSettings();
|
||||
}, []);
|
||||
const submitChange = async (text: string) => {
|
||||
await userSettingsTable?.upsert({ cloudHost: text });
|
||||
getSettings();
|
||||
toast({
|
||||
title: "Setting saved. Please refresh to see the changes.",
|
||||
status: "success",
|
||||
duration: 4000,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Stack>
|
||||
@@ -30,26 +32,16 @@ export default function CloudHostSetting() {
|
||||
</Text>
|
||||
<Flex gap={2} alignItems={"center"}>
|
||||
<Input
|
||||
ref={inputRef}
|
||||
onBlur={() => {
|
||||
console.log("onBlur", inputRef.current?.value);
|
||||
userSettingsTable?.upsert({ cloudHost: inputRef.current?.value });
|
||||
getSettings();
|
||||
toast({
|
||||
title: "Setting saved. Please refresh to see the changes.",
|
||||
status: "success",
|
||||
duration: 4000,
|
||||
});
|
||||
}}
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
onBlur={() => submitChange(text)}
|
||||
/>
|
||||
<Button
|
||||
size={"sm"}
|
||||
onClick={() => {
|
||||
inputRef.current?.setAttribute(
|
||||
"value",
|
||||
userSettingsTable?.defaultSettings.cloudHost!,
|
||||
);
|
||||
inputRef.current?.blur();
|
||||
const cloudHost = userSettingsTable?.defaultSettings.cloudHost!;
|
||||
setText(cloudHost);
|
||||
submitChange(cloudHost);
|
||||
}}
|
||||
>
|
||||
Reset
|
||||
|
||||
Reference in New Issue
Block a user