Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: fixed the download error.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 10, 2023
1 parent ce4adf3 commit 8dd6e92
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions Resources/downloadList.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
"https://github.com/ArchiDog1998/FFXIVRotations/releases/latest/download/DefaultRotations.dll",
"https://github.com/ArchiDog1998/FFXIVRotations/releases/latest/download/ExtraRotations.dll",
"Some url"
]
4 changes: 2 additions & 2 deletions RotationSolver/RotationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public static string GetAuthor(this Assembly assembly)
try
{
var name = assembly.GetName().Name;
return RotationLoadContext.AssemblyPaths.TryGetValue(name, out var path)
? FileVersionInfo.GetVersionInfo(path)?.CompanyName : name
return (RotationLoadContext.AssemblyPaths.TryGetValue(name, out var path)
? FileVersionInfo.GetVersionInfo(path)?.CompanyName : name)
?? name ?? "Unknown";
}
catch
Expand Down
6 changes: 3 additions & 3 deletions RotationSolver/RotationLoadContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ protected override Assembly Load(AssemblyName assemblyName)
//
}
}

return base.Load(assemblyName);
}

Expand All @@ -61,13 +60,14 @@ private Assembly LoadFromFile(string filePath)
if (!File.Exists(pdbPath)) return LoadFromStream(file);
using var pdbFile = File.Open(pdbPath, FileMode.Open, FileAccess.Read, FileShare.Read);
var assembly = LoadFromStream(file, pdbFile);
AssemblyPaths[assembly.GetName().Name] = filePath;
return assembly;
}

public static Assembly LoadFrom(string filePath)
{
var loadContext = new RotationLoadContext(new FileInfo(filePath).Directory);
return loadContext.LoadFromFile(filePath);
var assembly = loadContext.LoadFromFile(filePath);
AssemblyPaths[assembly.GetName().Name] = filePath;
return assembly;
}
}
13 changes: 9 additions & 4 deletions RotationSolver/Updaters/RotationUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,18 @@ public static async void GetAllCustomRotations()
{
if (File.Exists(filePath))
{
if(new FileInfo(filePath).Length == response.Content.Headers.ContentLength)
if (new FileInfo(filePath).Length == response.Content.Headers.ContentLength)
{
continue;
}
File.Delete(filePath);
}

using(var stream = new FileStream(filePath, File.Exists(filePath)
? FileMode.Open : FileMode.CreateNew))
{
await response.Content.CopyToAsync(stream);
}
await response.Content.CopyToAsync(new FileStream(filePath, File.Exists(filePath)
? FileMode.Open : FileMode.CreateNew));
}

hasDownload = true;
Expand All @@ -86,7 +91,7 @@ private static void LoadRotationsFromLocal(string relayFolder)
{
var directories = Service.Config.OtherLibs
.Where(Directory.Exists)
.Append(Path.GetDirectoryName(Assembly.GetAssembly(typeof(ICustomRotation)).Location))
//.Append(Path.GetDirectoryName(Assembly.GetAssembly(typeof(ICustomRotation)).Location))
.Append(relayFolder);

var assemblies = from dir in directories
Expand Down

0 comments on commit 8dd6e92

Please sign in to comment.