mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
clean up sync temp files when canceling jobs
This commit is contained in:
parent
7fd4b97481
commit
0f88525d61
@ -48,6 +48,10 @@
|
|||||||
"LabelFailed": "(failed)",
|
"LabelFailed": "(failed)",
|
||||||
"ButtonHelp": "Help",
|
"ButtonHelp": "Help",
|
||||||
"ButtonSave": "Save",
|
"ButtonSave": "Save",
|
||||||
|
"SyncJobStatusQueued": "Queued",
|
||||||
|
"SyncJobStatusInProgress": "In-Progress",
|
||||||
|
"SyncJobStatusCompleted": "Synced",
|
||||||
|
"SyncJobStatusCompletedWithError": "Synced with errors",
|
||||||
"LabelCollection": "Collection",
|
"LabelCollection": "Collection",
|
||||||
"HeaderAddToCollection": "Add to Collection",
|
"HeaderAddToCollection": "Add to Collection",
|
||||||
"NewCollectionNameExample": "Example: Star Wars Collection",
|
"NewCollectionNameExample": "Example: Star Wars Collection",
|
||||||
|
@ -183,7 +183,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
job.Status = SyncJobStatus.Completed;
|
job.Status = SyncJobStatus.Completed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (pct.Equals(0))
|
else if (pct.Equals(0) && jobItems.All(i => i.Status == SyncJobItemStatus.Queued))
|
||||||
{
|
{
|
||||||
job.Status = SyncJobStatus.Queued;
|
job.Status = SyncJobStatus.Queued;
|
||||||
}
|
}
|
||||||
@ -414,7 +414,6 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
}
|
}
|
||||||
|
|
||||||
jobItem.Progress = 0;
|
jobItem.Progress = 0;
|
||||||
jobItem.Status = SyncJobItemStatus.Converting;
|
|
||||||
|
|
||||||
var user = _userManager.GetUserById(job.UserId);
|
var user = _userManager.GetUserById(job.UserId);
|
||||||
|
|
||||||
@ -426,7 +425,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
|
|
||||||
else if (item is Audio)
|
else if (item is Audio)
|
||||||
{
|
{
|
||||||
await Sync(jobItem, (Audio)item, user, deviceProfile, enableConversion, progress, cancellationToken).ConfigureAwait(false);
|
await Sync(jobItem, job, (Audio)item, user, deviceProfile, enableConversion, progress, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (item is Photo)
|
else if (item is Photo)
|
||||||
@ -478,6 +477,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
{
|
{
|
||||||
// Save the job item now since conversion could take a while
|
// Save the job item now since conversion could take a while
|
||||||
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
||||||
|
await UpdateJobStatus(job).ConfigureAwait(false);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -611,7 +611,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Sync(SyncJobItem jobItem, Audio item, User user, DeviceProfile profile, bool enableConversion, IProgress<double> progress, CancellationToken cancellationToken)
|
private async Task Sync(SyncJobItem jobItem, SyncJob job, Audio item, User user, DeviceProfile profile, bool enableConversion, IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var options = _syncManager.GetAudioOptions(jobItem);
|
var options = _syncManager.GetAudioOptions(jobItem);
|
||||||
|
|
||||||
@ -636,6 +636,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
|
|
||||||
jobItem.Status = SyncJobItemStatus.Converting;
|
jobItem.Status = SyncJobItemStatus.Converting;
|
||||||
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
||||||
|
await UpdateJobStatus(job).ConfigureAwait(false);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -710,7 +711,12 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
return mediaSource.Path;
|
return mediaSource.Path;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetTemporaryPath(SyncJobItem jobItem)
|
public string GetTemporaryPath(SyncJob job)
|
||||||
|
{
|
||||||
|
return GetTemporaryPath(job.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTemporaryPath(string jobId)
|
||||||
{
|
{
|
||||||
var basePath = _config.GetSyncOptions().TemporaryPath;
|
var basePath = _config.GetSyncOptions().TemporaryPath;
|
||||||
|
|
||||||
@ -719,7 +725,12 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
basePath = Path.Combine(_config.CommonApplicationPaths.ProgramDataPath, "sync");
|
basePath = Path.Combine(_config.CommonApplicationPaths.ProgramDataPath, "sync");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Path.Combine(basePath, jobItem.JobId, jobItem.Id);
|
return Path.Combine(basePath, jobId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTemporaryPath(SyncJobItem jobItem)
|
||||||
|
{
|
||||||
|
return Path.Combine(GetTemporaryPath(jobItem.JobId), jobItem.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<MediaSourceInfo> GetEncodedMediaSource(string path, User user, bool isVideo)
|
private async Task<MediaSourceInfo> GetEncodedMediaSource(string path, User user, bool isVideo)
|
||||||
|
@ -309,6 +309,17 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
|
|
||||||
await _repo.DeleteJob(id).ConfigureAwait(false);
|
await _repo.DeleteJob(id).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var path = GetSyncJobProcessor().GetTemporaryPath(id);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_fileSystem.DeleteDirectory(path, true);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Error deleting directory {0}", ex, path);
|
||||||
|
}
|
||||||
|
|
||||||
if (SyncJobCancelled != null)
|
if (SyncJobCancelled != null)
|
||||||
{
|
{
|
||||||
EventHelper.FireEventIfNotNull(SyncJobCancelled, this, new GenericEventArgs<SyncJob>
|
EventHelper.FireEventIfNotNull(SyncJobCancelled, this, new GenericEventArgs<SyncJob>
|
||||||
@ -706,6 +717,17 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
var processor = GetSyncJobProcessor();
|
var processor = GetSyncJobProcessor();
|
||||||
|
|
||||||
await processor.UpdateJobStatus(jobItem.JobId).ConfigureAwait(false);
|
await processor.UpdateJobStatus(jobItem.JobId).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var path = processor.GetTemporaryPath(jobItem);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_fileSystem.DeleteDirectory(path, true);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Error deleting directory {0}", ex, path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task MarkJobItemForRemoval(string id)
|
public async Task MarkJobItemForRemoval(string id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user