|
@@ -14,10 +14,7 @@ public class ArchiveSelectionAction : IFileManagerSelectionAction
|
|
public async Task Execute(BaseFileAccess access, UI.Components.FileManager fileManager, FileEntry[] entries,
|
|
public async Task Execute(BaseFileAccess access, UI.Components.FileManager fileManager, FileEntry[] entries,
|
|
IServiceProvider provider)
|
|
IServiceProvider provider)
|
|
{
|
|
{
|
|
- if (!access.Actions.GetType().IsAssignableFrom(typeof(IArchiveFileActions)))
|
|
|
|
- throw new DisplayException("This file access does not support archiving");
|
|
|
|
-
|
|
|
|
- var archiveAccess = access as IArchiveFileActions;
|
|
|
|
|
|
+ var archiveAccess = access.Actions as IArchiveFileActions;
|
|
|
|
|
|
if (archiveAccess == null)
|
|
if (archiveAccess == null)
|
|
throw new DisplayException("This file access does not support archiving");
|
|
throw new DisplayException("This file access does not support archiving");
|
|
@@ -29,10 +26,30 @@ public class ArchiveSelectionAction : IFileManagerSelectionAction
|
|
|
|
|
|
if (string.IsNullOrEmpty(fileName) || fileName.Contains("..")) // => canceled
|
|
if (string.IsNullOrEmpty(fileName) || fileName.Contains("..")) // => canceled
|
|
return;
|
|
return;
|
|
-
|
|
|
|
- await archiveAccess.Archive(
|
|
|
|
- access.CurrentDirectory + fileName,
|
|
|
|
- entries.Select(x => access.CurrentDirectory + x.Name).ToArray()
|
|
|
|
- );
|
|
|
|
|
|
+
|
|
|
|
+ var toastService = provider.GetRequiredService<ToastService>();
|
|
|
|
+
|
|
|
|
+ await toastService.CreateProgress("fileManagerArchive", "Archiving... Please be patient");
|
|
|
|
+
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ await archiveAccess.Archive(
|
|
|
|
+ access.CurrentDirectory + fileName,
|
|
|
|
+ entries.Select(x => access.CurrentDirectory + x.Name).ToArray()
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ await toastService.Success("Successfully created archive");
|
|
|
|
+ }
|
|
|
|
+ catch (Exception e)
|
|
|
|
+ {
|
|
|
|
+ Logger.Warn($"An error occured while archiving items ({entries.Length}):");
|
|
|
|
+ Logger.Warn(e);
|
|
|
|
+
|
|
|
|
+ await toastService.Danger("An unknown error occured while creating archive");
|
|
|
|
+ }
|
|
|
|
+ finally
|
|
|
|
+ {
|
|
|
|
+ await toastService.RemoveProgress("fileManagerArchive");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|