Skip to content

Commit 6cf727e

Browse files
authored
Merge pull request #9752 from decentraland/chore/sync
chore: sync main to dev
2 parents 3ccb3bc + 7d55245 commit 6cf727e

29 files changed

Lines changed: 2100 additions & 67 deletions

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,9 @@ Explorer/.cursorignore
8484
# ReSharper CLI download for local linting (scripts/lint/download-resharper.sh)
8585
/rsharp/
8686
rsharp.zip
87+
88+
# abgen sidecar server binary (fetched from release, not committed)
89+
Explorer/Assets/StreamingAssets/abgen
90+
Explorer/Assets/StreamingAssets/abgen.exe
91+
Explorer/Assets/StreamingAssets/abgen.exe.meta
92+
Explorer/Assets/StreamingAssets/abgen.meta
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#nullable enable
2+
3+
using System;
4+
using System.IO;
5+
6+
namespace ECS.StreamableLoading.AssetBundles
7+
{
8+
/// <summary>
9+
/// Locations and maintenance of the abgen sidecar's on-disk bundle stores under
10+
/// <c>persistentDataPath</c>, one home per server flavor.
11+
/// </summary>
12+
public static class AbgenBundleDiskCache
13+
{
14+
/// <summary>Sidecar server home under persistentDataPath: bin/ (the binary), cache/ and out/ (bundles).</summary>
15+
public const string SIDECAR_DIR = "abgen";
16+
17+
/// <summary>Sidecar home for the local-scene-development flavor; kept apart from the catalyst one.</summary>
18+
public const string SIDECAR_LSD_DIR = "abgen-lsd";
19+
20+
/// <summary>
21+
/// Every disk root the sidecar writes bundles to: each flavor's cache/ and out/ directories —
22+
/// deliberately never a sidecar's bin/, which holds the downloaded binary. Reads
23+
/// persistentDataPath; call from the main thread.
24+
/// </summary>
25+
public static string[] AllBundleRoots()
26+
{
27+
string persistent = UnityEngine.Application.persistentDataPath;
28+
29+
return new[]
30+
{
31+
Path.Combine(persistent, SIDECAR_DIR, "cache"),
32+
Path.Combine(persistent, SIDECAR_DIR, "out"),
33+
Path.Combine(persistent, SIDECAR_LSD_DIR, "cache"),
34+
Path.Combine(persistent, SIDECAR_LSD_DIR, "out"),
35+
};
36+
}
37+
38+
/// <summary>
39+
/// Deletes every cached bundle under <paramref name="root" />, including in-progress temp files.
40+
/// Files that cannot be deleted (e.g. memory-mapped by a loaded AssetBundle on Windows) are skipped
41+
/// and counted. Walks every shard — call from a background thread.
42+
/// </summary>
43+
public static ClearResult ClearAll(string root)
44+
{
45+
var result = new ClearResult();
46+
47+
if (!Directory.Exists(root)) return result;
48+
49+
foreach (string file in Directory.EnumerateFiles(root, "*", SearchOption.AllDirectories))
50+
{
51+
try
52+
{
53+
long size = new FileInfo(file).Length;
54+
File.Delete(file);
55+
result.DeletedFiles++;
56+
result.DeletedBytes += size;
57+
}
58+
catch (Exception e) when (e is IOException or UnauthorizedAccessException) { result.SkippedFiles++; }
59+
}
60+
61+
return result;
62+
}
63+
64+
/// <summary>Aggregate of <see cref="ClearAll(string)" /> over every root.</summary>
65+
public static ClearResult ClearAll(string[] roots)
66+
{
67+
var total = new ClearResult();
68+
69+
foreach (string root in roots)
70+
{
71+
ClearResult result = ClearAll(root);
72+
total.DeletedFiles += result.DeletedFiles;
73+
total.DeletedBytes += result.DeletedBytes;
74+
total.SkippedFiles += result.SkippedFiles;
75+
}
76+
77+
return total;
78+
}
79+
80+
public struct ClearResult
81+
{
82+
public int DeletedFiles;
83+
public long DeletedBytes;
84+
public int SkippedFiles;
85+
}
86+
}
87+
}

Explorer/Assets/DCL/Infrastructure/ECS/Unity/StreamableLoading/AssetBundles/AbgenBundleDiskCache.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)