Skip to content

Commit

Permalink
Fix small bugs (TagStudioDev#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thesacraft authored May 31, 2024
1 parent 868b553 commit 779a251
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
36 changes: 21 additions & 15 deletions tagstudio/src/core/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,21 +857,27 @@ def refresh_dir(self) -> Generator:
start_time = time.time()
for f in self.library_dir.glob("**/*"):
# p = Path(os.path.normpath(f))
if (
"$RECYCLE.BIN" not in f.parts
and TS_FOLDER_NAME not in f.parts
and "tagstudio_thumbs" not in f.parts
and not f.is_dir()
):
if f.suffix not in self.ignored_extensions:
self.dir_file_count += 1
file = f.relative_to(self.library_dir)
try:
_ = self.filename_to_entry_id_map[file]
except KeyError:
# print(file)
self.files_not_in_library.append(file)

try:
if f.is_dir():
print(f)
if (
"$RECYCLE.BIN" not in f.parts
and TS_FOLDER_NAME not in f.parts
and "tagstudio_thumbs" not in f.parts
and not f.is_dir()
):
if f.suffix not in self.ignored_extensions:
self.dir_file_count += 1
file = f.relative_to(self.library_dir)
try:
_ = self.filename_to_entry_id_map[file]
except KeyError:
# print(file)
self.files_not_in_library.append(file)
except PermissionError:
logging.info(
f"The File/Folder {f} cannot be accessed, because it requires higher permission!"
)
# sys.stdout.write(f'\r[LIBRARY] {self.dir_file_count} files found in "{self.library_dir}"...')
# sys.stdout.flush()
end_time = time.time()
Expand Down
16 changes: 11 additions & 5 deletions tagstudio/src/qt/widgets/preview_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,17 @@ def update_widgets(self):
if filepath.suffix.lower() in IMAGE_TYPES:
image = Image.open(str(filepath))
elif filepath.suffix.lower() in RAW_IMAGE_TYPES:
with rawpy.imread(filepath) as raw:
rgb = raw.postprocess()
image = Image.new(
"L", (rgb.shape[1], rgb.shape[0]), color="black"
)
try:
with rawpy.imread(filepath) as raw:
rgb = raw.postprocess()
image = Image.new(
"L", (rgb.shape[1], rgb.shape[0]), color="black"
)
except (
rawpy._rawpy.LibRawIOError,
rawpy._rawpy.LibRawFileUnsupportedError,
):
pass
elif filepath.suffix.lower() in VIDEO_TYPES:
video = cv2.VideoCapture(str(filepath))
video.set(cv2.CAP_PROP_POS_FRAMES, 0)
Expand Down
5 changes: 4 additions & 1 deletion tagstudio/src/qt/widgets/thumb_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ def render(
logging.info(
f"[ThumbRenderer]{WARNING} Couldn't Render thumbnail for {_filepath} (because of {e})"
)
except rawpy._rawpy.LibRawIOError:
except (
rawpy._rawpy.LibRawIOError,
rawpy._rawpy.LibRawFileUnsupportedError,
):
logging.info(
f"[ThumbRenderer]{ERROR} Couldn't Render thumbnail for raw image {_filepath}"
)
Expand Down

0 comments on commit 779a251

Please sign in to comment.