CopyCoordinator
public static class CopyCoordinatorCoordinates asset copy operations across parallel tasks to prevent duplicate work, race conditions, and excessive AssetDatabase.Refresh() calls. Uses smart caching with reference counting and file-existence validation.
Methods
Section titled “Methods”
AcquireOrCopy(string, string, Func<Task>)
Section titled “AcquireOrCopy(string, string, Func<Task>)”public static Task<string> AcquireOrCopy(string guid, string targetFolder, Func<Task<string>> copyFunc)Attempts to acquire a copy operation for the given GUID. If another operation is in-flight for the same GUID+folder, awaits it. If already completed and valid, returns the cached path. Otherwise, starts the copy operation.
Parameters
| Name | Type | Description |
|---|---|---|
guid |
System.String | The GUID of the asset |
targetFolder |
System.String | The destination folder |
copyFunc |
System.Func{System.Threading.Tasks.Task{System.String}} | The function to execute the actual copy |
Returns
System.Threading.Tasks.Task{System.String} — The target path of the copied file
ValidateAndGet(string, string)
Section titled “ValidateAndGet(string, string)”public static string ValidateAndGet(string guid, string targetFolder)Validates and returns a cached path if the file still exists.
Parameters
| Name | Type | Description |
|---|---|---|
guid |
System.String | The GUID of the asset |
targetFolder |
System.String | The destination folder |
Returns
System.String — The cached path if valid, null otherwise
Invalidate(string, string)
Section titled “Invalidate(string, string)”public static void Invalidate(string guid, string targetFolder)Invalidates a specific cached entry by GUID and folder.
Parameters
| Name | Type | Description |
|---|---|---|
guid |
System.String | |
targetFolder |
System.String | |
InvalidateFolder(string)
Section titled “InvalidateFolder(string)”public static void InvalidateFolder(string folderPath)Invalidates all cached entries for files in the specified folder.
Parameters
| Name | Type | Description |
|---|---|---|
folderPath |
System.String | The folder path (can be partial, will match contains) |
Reset()
Section titled “Reset()”public static void Reset()Clears all cached entries. Call this at the start of bulk operations to ensure fresh state.
ClassifyFile(string, string, string)
Section titled “ClassifyFile(string, string, string)”public static CopyCoordinator.FileCategory ClassifyFile(string sourcePath, string guid, string fileType)Classifies a file based on its metadata availability.
Parameters
| Name | Type | Description |
|---|---|---|
sourcePath |
System.String | The source file path |
guid |
System.String | The known GUID, if any |
fileType |
System.String | The file extension without dot |
Returns
AssetInventory.CopyCoordinator.FileCategory — The file category
IsScriptType(string)
Section titled “IsScriptType(string)”public static bool IsScriptType(string fileType)Checks if the file type is a script-related type that triggers domain reload.
Parameters
| Name | Type | Description |
|---|---|---|
fileType |
System.String |
Returns
System.Boolean — No return description is available.
GetStats()
Section titled “GetStats()”public static (int totalEntries, int inFlight, int completed) GetStats()Gets the current cache statistics for debugging/monitoring.
Returns
System.ValueTuple{System.Int32,System.Int32,System.Int32} — No return description is available.