tikz-gallery-generator

Custum build of stapix for tikz.pablopie.xyz

Commit
22e6169799680a5c60015ebb142561e54370a99a
Parent
9a1bf4442cb206612c62a89085dc8a46a69eddd8
Author
Pablo <pablo-pie@riseup.net>
Date

Fixed symlink overriding issue

Diffstat

1 file changed, 8 insertions, 1 deletion

Status File Name N° Changes Insertions Deletions
Modified src/main.rs 9 8 1
diff --git a/src/main.rs b/src/main.rs
@@ -504,7 +504,14 @@ fn render_thumbnail(pic: GalleryEntry, full_build: bool) -> RenderResult {
                 }
             };
 
-            // TODO: Remove symlink and remake it if necessary
+            // Delete the thumbnail file if it exists already: fs::symlink does
+            // not override files
+            if let Ok(meta) = fs::symlink_metadata(&thumb_path) {
+                if meta.is_file() || meta.is_symlink() {
+                    let _ = fs::remove_file(&thumb_path);
+                }
+            }
+
             if let Err(err) = unix::fs::symlink(&src_path, &thumb_path) {
                 errorln!(
                     "Failed to create symlink {thumb:?} -> {src:?}: {err}",