Fixed: Try to set last write time on files moved to recycle bin
Closes #2057
This commit is contained in:
parent
6d0a3b1ca4
commit
fbcc0b76bf
|
@ -62,11 +62,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
_diskProvider.FolderSetLastWriteTime(destination, DateTime.UtcNow);
|
_diskProvider.FolderSetLastWriteTime(destination, DateTime.UtcNow);
|
||||||
foreach (var file in _diskProvider.GetFiles(destination, SearchOption.AllDirectories))
|
foreach (var file in _diskProvider.GetFiles(destination, SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
if (OsInfo.IsWindows)
|
SetLastWriteTime(file, DateTime.UtcNow);
|
||||||
{
|
|
||||||
//TODO: Better fix than this for non-Windows?
|
|
||||||
_diskProvider.FileSetLastWriteTime(file, DateTime.UtcNow);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Debug("Folder has been moved to the recycling bin: {0}", destination);
|
_logger.Debug("Folder has been moved to the recycling bin: {0}", destination);
|
||||||
|
@ -124,11 +120,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Better fix than this for non-Windows?
|
SetLastWriteTime(destination, DateTime.UtcNow);
|
||||||
if (OsInfo.IsWindows)
|
|
||||||
{
|
|
||||||
_diskProvider.FileSetLastWriteTime(destination, DateTime.UtcNow);
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.Debug("File has been moved to the recycling bin: {0}", destination);
|
_logger.Debug("File has been moved to the recycling bin: {0}", destination);
|
||||||
}
|
}
|
||||||
|
@ -192,6 +184,18 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
_logger.Debug("Recycling Bin has been cleaned up.");
|
_logger.Debug("Recycling Bin has been cleaned up.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetLastWriteTime(string file, DateTime dateTime)
|
||||||
|
{
|
||||||
|
// Swallow any IOException that may be thrown due to "Invalid parameter"
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_diskProvider.FileSetLastWriteTime(file, dateTime);
|
||||||
|
}
|
||||||
|
catch (IOException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Execute(CleanUpRecycleBinCommand message)
|
public void Execute(CleanUpRecycleBinCommand message)
|
||||||
{
|
{
|
||||||
Cleanup();
|
Cleanup();
|
||||||
|
|
Loading…
Reference in New Issue