mirror of https://github.com/lidarr/Lidarr
Fixed LastWriteTime
This commit is contained in:
parent
82d4933152
commit
88afc19716
|
@ -39,7 +39,7 @@ namespace NzbDrone.Common
|
||||||
string GetPathRoot(string path);
|
string GetPathRoot(string path);
|
||||||
void SetPermissions(string filename, WellKnownSidType accountSid, FileSystemRights rights, AccessControlType controlType);
|
void SetPermissions(string filename, WellKnownSidType accountSid, FileSystemRights rights, AccessControlType controlType);
|
||||||
bool IsParent(string parentPath, string childPath);
|
bool IsParent(string parentPath, string childPath);
|
||||||
void SetFolderAccessTime(string path, DateTime time){
|
void SetFolderWriteTime(string path, DateTime time);
|
||||||
FileAttributes GetFileAttributes(string path);
|
FileAttributes GetFileAttributes(string path);
|
||||||
void EmptyFolder(string path);
|
void EmptyFolder(string path);
|
||||||
}
|
}
|
||||||
|
@ -442,6 +442,10 @@ namespace NzbDrone.Common
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetFolderWriteTime(string path, DateTime time)
|
||||||
|
{
|
||||||
|
Directory.SetLastWriteTimeUtc(path, time);
|
||||||
|
}
|
||||||
|
|
||||||
private static void RemoveReadOnly(string path)
|
private static void RemoveReadOnly(string path)
|
||||||
{
|
{
|
||||||
|
@ -452,10 +456,6 @@ namespace NzbDrone.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetFolderAccessTime(string path, DateTime time){
|
|
||||||
Directory.SetLastWriteTimeUtc(path,time);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileAttributes GetFileAttributes(string path)
|
public FileAttributes GetFileAttributes(string path)
|
||||||
{
|
{
|
||||||
return File.GetAttributes(path);
|
return File.GetAttributes(path);
|
||||||
|
|
|
@ -42,9 +42,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
var episodes = _episodeService.GetEpisodesByFileId(episodeFile.Id);
|
var episodes = _episodeService.GetEpisodesByFileId(episodeFile.Id);
|
||||||
var newFileName = _buildFileNames.BuildFilename(episodes, series, episodeFile);
|
var newFileName = _buildFileNames.BuildFilename(episodes, series, episodeFile);
|
||||||
var filePath = _buildFileNames.BuildFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
|
var filePath = _buildFileNames.BuildFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
|
||||||
MoveFile(episodeFile, filePath);
|
MoveFile(episodeFile, series, filePath);
|
||||||
_diskProvider.SetFolderAccessTime( Path.GetDirectoryName(filePath), episodeFile.DateAdded);
|
|
||||||
_diskProvider.SetFolderAccessTime( series.Path, episodeFile.DateAdded);
|
|
||||||
|
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
@ -53,14 +51,12 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
{
|
{
|
||||||
var newFileName = _buildFileNames.BuildFilename(localEpisode.Episodes, localEpisode.Series, episodeFile);
|
var newFileName = _buildFileNames.BuildFilename(localEpisode.Episodes, localEpisode.Series, episodeFile);
|
||||||
var filePath = _buildFileNames.BuildFilePath(localEpisode.Series, localEpisode.SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
|
var filePath = _buildFileNames.BuildFilePath(localEpisode.Series, localEpisode.SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
|
||||||
MoveFile(episodeFile, filePath);
|
MoveFile(episodeFile, localEpisode.Series, filePath);
|
||||||
_diskProvider.SetFolderAccessTime( Path.GetDirectoryName(filePath), episodeFile.DateAdded);
|
|
||||||
_diskProvider.SetFolderAccessTime( localEpisode.Series.Path, episodeFile.DateAdded);
|
|
||||||
|
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MoveFile(EpisodeFile episodeFile, string destinationFilename)
|
private void MoveFile(EpisodeFile episodeFile, Series series, string destinationFilename)
|
||||||
{
|
{
|
||||||
if (!_diskProvider.FileExists(episodeFile.Path))
|
if (!_diskProvider.FileExists(episodeFile.Path))
|
||||||
{
|
{
|
||||||
|
@ -77,6 +73,17 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
_logger.Debug("Moving [{0}] > [{1}]", episodeFile.Path, destinationFilename);
|
_logger.Debug("Moving [{0}] > [{1}]", episodeFile.Path, destinationFilename);
|
||||||
_diskProvider.MoveFile(episodeFile.Path, destinationFilename);
|
_diskProvider.MoveFile(episodeFile.Path, destinationFilename);
|
||||||
|
|
||||||
|
_logger.Trace("Setting last write time on series folder: {0}", series.Path);
|
||||||
|
_diskProvider.SetFolderWriteTime(series.Path, episodeFile.DateAdded);
|
||||||
|
|
||||||
|
if (series.SeasonFolder)
|
||||||
|
{
|
||||||
|
var seasonFolder = Path.GetDirectoryName(episodeFile.Path);
|
||||||
|
|
||||||
|
_logger.Trace("Setting last write time on season folder: {0}", seasonFolder);
|
||||||
|
_diskProvider.SetFolderWriteTime(seasonFolder, episodeFile.DateAdded);
|
||||||
|
}
|
||||||
|
|
||||||
//Wrapped in Try/Catch to prevent this from causing issues with remote NAS boxes, the move worked, which is more important.
|
//Wrapped in Try/Catch to prevent this from causing issues with remote NAS boxes, the move worked, which is more important.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue