public async Task <Tuple <string, bool> > TryGetFromStoreAsync(string tag, TimeSpan timeout) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); ImageBuilder.TraceSource.WriteInfo( TraceType, "Downloading {0} from store.", tag); bool exists = false; string value = null; string tempFileName = ImageBuilderUtility.GetTempFileName(this.localImageBuilderRoot); try { bool doesExsit = await this.ImageStore.DoesContentExistAsync(tag, timeoutHelper.GetRemainingTime()); if (doesExsit) { await this.ImageStore.DownloadContentAsync(tag, tempFileName, timeoutHelper.GetRemainingTime(), CopyFlag.AtomicCopy); ImageBuilderUtility.RemoveReadOnlyFlag(tempFileName); value = ImageBuilderUtility.ReadStringFromFile(tempFileName); exists = true; } } finally { ImageBuilderUtility.DeleteTempLocation(tempFileName); } return(new Tuple <string, bool>(value, exists)); }
public string TryGetFromStore(string tag, out bool exists, TimeSpan timeout) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); ImageBuilder.TraceSource.WriteInfo( TraceType, "Downloading {0} from store.", tag); exists = false; string value = null; string tempFileName = ImageBuilderUtility.GetTempFileName(this.localImageBuilderRoot); try { if (this.ImageStore.DoesContentExist(tag, timeoutHelper.GetRemainingTime())) { this.ImageStore.DownloadContent(tag, tempFileName, timeoutHelper.GetRemainingTime(), CopyFlag.AtomicCopy); ImageBuilderUtility.RemoveReadOnlyFlag(tempFileName); value = ImageBuilderUtility.ReadStringFromFile(tempFileName); exists = true; } } finally { ImageBuilderUtility.DeleteTempLocation(tempFileName); } return(value); }
public static string EnsureHashFile(string resourcePath, string hashFilePath, bool imageStoreServiceEnabled) { if (!FabricFile.Exists(hashFilePath)) { string checksum = ChecksumUtility.ComputeHash(resourcePath, imageStoreServiceEnabled); ImageBuilderUtility.WriteStringToFile(hashFilePath, checksum); return(checksum); } else { return(ImageBuilderUtility.ReadStringFromFile(hashFilePath)); } }