mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(nodes): use send2trash to delete images, fix thumbnail_path
This commit is contained in:
parent
0ab62b0343
commit
0cc739afc8
@ -5,10 +5,11 @@ from glob import glob
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
from typing import Dict, List, Tuple
|
from typing import Dict, List
|
||||||
|
|
||||||
from PIL.Image import Image
|
from PIL.Image import Image
|
||||||
import PIL.Image as PILImage
|
import PIL.Image as PILImage
|
||||||
|
from send2trash import send2trash
|
||||||
from invokeai.app.api.models.images import (
|
from invokeai.app.api.models.images import (
|
||||||
ImageResponse,
|
ImageResponse,
|
||||||
ImageResponseMetadata,
|
ImageResponseMetadata,
|
||||||
@ -244,15 +245,15 @@ class DiskImageStorage(ImageStorageBase):
|
|||||||
image_path = self.get_path(image_type, basename)
|
image_path = self.get_path(image_type, basename)
|
||||||
|
|
||||||
if os.path.exists(image_path):
|
if os.path.exists(image_path):
|
||||||
os.remove(image_path)
|
send2trash(image_path)
|
||||||
if image_path in self.__cache:
|
if image_path in self.__cache:
|
||||||
del self.__cache[image_path]
|
del self.__cache[image_path]
|
||||||
|
|
||||||
thumbnail_name = get_thumbnail_name(image_name)
|
thumbnail_name = get_thumbnail_name(image_name)
|
||||||
thumbnail_path = self.get_path(image_type, thumbnail_name, True)
|
thumbnail_path = self.get_path(image_type, thumbnail_name, True)
|
||||||
|
|
||||||
if os.path.exists(image_path):
|
if os.path.exists(thumbnail_path):
|
||||||
os.remove(thumbnail_path)
|
send2trash(thumbnail_path)
|
||||||
if thumbnail_path in self.__cache:
|
if thumbnail_path in self.__cache:
|
||||||
del self.__cache[thumbnail_path]
|
del self.__cache[thumbnail_path]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user