diff --git a/DownloadTask.cs b/DownloadTask.cs index 6ae5fb2..a5122a2 100644 --- a/DownloadTask.cs +++ b/DownloadTask.cs @@ -699,7 +699,7 @@ StateCounter counter // the file is now fully written to, so duplicate it if // necessary - await DuplicateFile(filesPath, outputPaths, path); + await this.DuplicateFile(filesPath, outputPaths, path); this.StateData += 1; counter.Added += 1; @@ -707,14 +707,14 @@ StateCounter counter } } - internal static string MakePathPartsSafe(string input) { + private static string MakePathPartsSafe(string input) { var cleaned = input .Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar, '\\', '/') .Select(MakeFileNameSafe); return string.Join(Path.DirectorySeparatorChar, cleaned); } - internal static string MakeFileNameSafe(string input) { + private static string MakeFileNameSafe(string input) { var invalid = Path.GetInvalidFileNameChars(); var sb = new StringBuilder(input.Length); @@ -729,7 +729,7 @@ internal static string MakeFileNameSafe(string input) { return sb.ToString(); } - internal static string[] GetOutputPaths(IReadOnlyCollection> files) { + private static string[] GetOutputPaths(IReadOnlyCollection> files) { return files .Select(file => { var outputPath = file[3]; @@ -810,6 +810,11 @@ private void RemoveOldFiles() { this.State = State.RemovingOldFiles; this.SetStateData(0, 0); + Plugin.Log.Info("expected files:"); + foreach (var exp in this.ExpectedFiles) { + Plugin.Log.Info($" {exp}"); + } + // find old, normal files no longer being used to remove var filesPath = Path.Join(this.PenumbraModPath, "files"); @@ -820,6 +825,11 @@ private void RemoveOldFiles() { .Select(path => path.ToLowerInvariant()) .ToHashSet(); + Plugin.Log.Info("present files:"); + foreach (var exp in presentFiles) { + Plugin.Log.Info($" {exp}"); + } + // remove the files that we expect from the list of already-existing // files - these are the files to remove now presentFiles.ExceptWith(this.ExpectedFiles); @@ -1007,16 +1017,21 @@ private async Task ConstructHeliosphereMeta(IDownloadTask_GetVe } private static string GetReplacedPath(List file) { + var gamePath = file[2]!; var outputPath = file[3]; var replacedPath = outputPath == null ? Path.Join( file[0] ?? DefaultFolder, file[1] ?? DefaultFolder, - MakePathPartsSafe(file[2]!) + MakePathPartsSafe(gamePath) ) : MakePathPartsSafe(outputPath); + if (Path.GetExtension(replacedPath) == string.Empty) { + replacedPath = Path.ChangeExtension(replacedPath, Path.GetExtension(gamePath)); + } + return replacedPath; }