Skip to content

Commit

Permalink
fix library setup restart when interrupted
Browse files Browse the repository at this point in the history
  • Loading branch information
amakropoulos committed Sep 8, 2024
1 parent a5d02b6 commit d3eef84
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions Runtime/LLMUnitySetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,24 +366,18 @@ static async Task DownloadAndExtractInsideDirectory(string url, string path, str

static async Task DownloadLibrary()
{
void DeleteFileAndMeta(string path)
{
if (File.Exists(path + ".meta")) File.Delete(path + ".meta");
if (File.Exists(path)) File.Delete(path);
}
if (libraryProgress < 1) return;
libraryProgress = 0;

try
{
string setupDir = Path.Combine(libraryPath, "setup");
Directory.CreateDirectory(setupDir);

string lockFile = Path.Combine(setupDir, "LLMUnitySetup.lock");
if (File.Exists(lockFile)) return;
CreateEmptyFile(lockFile);

libraryProgress = 0;
// setup LlamaLib in StreamingAssets
await DownloadAndExtractInsideDirectory(LlamaLibURL, libraryPath, setupDir);

// setup LlamaLib in Plugins for Android
AssetDatabase.StartAssetEditing();
string androidDir = Path.Combine(libraryPath, "android");
if (Directory.Exists(androidDir))
Expand All @@ -397,15 +391,15 @@ void DeleteFileAndMeta(string path)
}
AssetDatabase.StopAssetEditing();

// setup LlamaLib extras in StreamingAssets
if (FullLlamaLib) await DownloadAndExtractInsideDirectory(LlamaLibExtensionURL, libraryPath, setupDir);

libraryProgress = 1;
DeleteFileAndMeta(lockFile);
}
catch (Exception e)
{
LogError(e.Message);
}

libraryProgress = 1;
}

private static void SetLibraryProgress(float progress)
Expand Down

0 comments on commit d3eef84

Please sign in to comment.