From a7c7bd99258899e46962a718423d30135c5c86e6 Mon Sep 17 00:00:00 2001 From: rmcrackan Date: Sun, 5 Apr 2026 15:41:58 -0400 Subject: [PATCH] #1716 - fix NAS bug --- Source/FileLiberator/Processable.cs | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Source/FileLiberator/Processable.cs b/Source/FileLiberator/Processable.cs index d6941ee5..813029ab 100644 --- a/Source/FileLiberator/Processable.cs +++ b/Source/FileLiberator/Processable.cs @@ -120,15 +120,35 @@ public abstract class Processable { if (!fileInfo.Exists) return; - fileInfo.CreationTimeUtc = getTimeValue(Configuration.CreationTime) ?? fileInfo.CreationTimeUtc; - fileInfo.LastWriteTimeUtc = getTimeValue(Configuration.LastWriteTime) ?? fileInfo.LastWriteTimeUtc; - DateTime? getTimeValue(Configuration.DateTimeSource source) => source switch { Configuration.DateTimeSource.Added => libraryBook.DateAdded, Configuration.DateTimeSource.Published => libraryBook.Book.DatePublished, _ => null, }; - } + if (getTimeValue(Configuration.CreationTime) is { } creationUtc) + { + try + { + fileInfo.CreationTimeUtc = creationUtc; + } + catch (Exception ex) when (ex is UnauthorizedAccessException or IOException) + { + Serilog.Log.Logger.Debug(ex, "Could not set creation time for {Path}; filesystem may not support it.", fileInfo.FullName); + } + } + + if (getTimeValue(Configuration.LastWriteTime) is { } lastWriteUtc) + { + try + { + fileInfo.LastWriteTimeUtc = lastWriteUtc; + } + catch (Exception ex) when (ex is UnauthorizedAccessException or IOException) + { + Serilog.Log.Logger.Debug(ex, "Could not set last write time for {Path}; filesystem may not support it.", fileInfo.FullName); + } + } + } }