private static Asset GetStatusCachedIfPossible(string from, CachedStatusMode mode) { Asset asset = Provider.CacheStatus(from); if (asset == null || asset.IsState(Asset.States.Updating)) { if (mode == CachedStatusMode.Sync) { // Fetch status Task statusTask = Provider.Status(from, false); statusTask.Wait(); if (statusTask.success) { asset = Provider.CacheStatus(from); } else { asset = null; } } } return(asset); }
public static bool IsOpenForEdit(string assetPath, out string message, StatusQueryOptions statusOptions) { message = ""; if (!Provider.enabled) { return(true); } if (string.IsNullOrEmpty(assetPath)) { return(true); } Asset asset = null; if (statusOptions == StatusQueryOptions.UseCachedIfPossible || statusOptions == StatusQueryOptions.UseCachedAsync) { CachedStatusMode mode = statusOptions == StatusQueryOptions.UseCachedAsync ? CachedStatusMode.Async : CachedStatusMode.Sync; asset = GetStatusCachedIfPossible(assetPath, mode); } else { asset = GetStatusForceUpdate(assetPath); } if (asset == null) { if (Provider.onlineState == OnlineState.Offline && Provider.offlineReason != string.Empty) { message = Provider.offlineReason; } return(false); } return(Provider.IsOpenForEdit(asset)); }