Skip to content

Commit f0d2ea2

Browse files
committed
fix library setup restart when interrupted
1 parent 6973753 commit f0d2ea2

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

Runtime/LLMUnitySetup.cs

+7-13
Original file line numberDiff line numberDiff line change
@@ -366,24 +366,18 @@ static async Task DownloadAndExtractInsideDirectory(string url, string path, str
366366

367367
static async Task DownloadLibrary()
368368
{
369-
void DeleteFileAndMeta(string path)
370-
{
371-
if (File.Exists(path + ".meta")) File.Delete(path + ".meta");
372-
if (File.Exists(path)) File.Delete(path);
373-
}
369+
if (libraryProgress < 1) return;
370+
libraryProgress = 0;
374371

375372
try
376373
{
377374
string setupDir = Path.Combine(libraryPath, "setup");
378375
Directory.CreateDirectory(setupDir);
379376

380-
string lockFile = Path.Combine(setupDir, "LLMUnitySetup.lock");
381-
if (File.Exists(lockFile)) return;
382-
CreateEmptyFile(lockFile);
383-
384-
libraryProgress = 0;
377+
// setup LlamaLib in StreamingAssets
385378
await DownloadAndExtractInsideDirectory(LlamaLibURL, libraryPath, setupDir);
386379

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

394+
// setup LlamaLib extras in StreamingAssets
400395
if (FullLlamaLib) await DownloadAndExtractInsideDirectory(LlamaLibExtensionURL, libraryPath, setupDir);
401-
402-
libraryProgress = 1;
403-
DeleteFileAndMeta(lockFile);
404396
}
405397
catch (Exception e)
406398
{
407399
LogError(e.Message);
408400
}
401+
402+
libraryProgress = 1;
409403
}
410404

411405
private static void SetLibraryProgress(float progress)

0 commit comments

Comments
 (0)