public string getDownloadKey(UPLOAD_INFO f) { string key; lock (pendingUploads) { while (true) { string random1 = Path.GetRandomFileName().Substring(0, 8); string random2 = Path.GetRandomFileName().Substring(0, 8); key = random1 + random2; try { //ADD TIMEOUT NOT SUPPORTED pendingUploads.Add(key, f); break; } catch (ArgumentException) { /* keep trying */ } } } String containerName, blobName, containerAzureName; String[] arr = f.path.Split(':'); containerName = arr[0]; blobName = arr[1]; if (containerName.Equals(f.username)) { containerAzureName = azureLink.findUserId(f.username).ToString(); } else { int uid = azureLink.findUserId(f.username); IResourceManage r = new Resource(); int rid = r.getContainerID(uid, containerName); if (rid == -1) { pendingUploads.Remove(key); throw new DBLikeExceptions.CloudContainerNotFoundException(); } if (!r.canWrite(uid, rid)) { pendingUploads.Remove(key); throw new DBLikeExceptions.UnauthorizedAccessException(); } /* TODO: improve this */ containerAzureName = new DBManager.ResourceM() .getResourceById(new DBManager.DBAccess().getDBAccess(), rid) .getContainerName(); } if (VALIDATE_OLD_HASH) { try { var blobMgr = new BlobStorageManager.BlobFileHandler(); String oldHash = blobMgr.getBlobMD5HashValue(containerAzureName, blobName); if (oldHash != null && !oldHash.Equals(f.prevHash)) { throw new DBLikeExceptions.HashConflictException(); } } catch (DBLikeExceptions.CloudBlobNotFoundException) { /* new file, no old hash */ } } return(key); }