private bool TryDownloadFileShard(
     BackblazeB2AuthorizationSession authorizationSession,
     string fileShardID,
     string filePathDestination,
     FileResult remoteFile
     )
 {
     this.Verbose($"Starting download of: {fileShardID}");
     using (DownloadFileAction fileShardDownload =
                new DownloadFileAction(authorizationSession, filePathDestination, remoteFile.FileID))
     {
         BackblazeB2ActionResult <BackblazeB2DownloadFileResult> downloadResult = fileShardDownload.Execute();
         if (downloadResult.HasErrors)
         {
             this.Critical($"Exception occurred during downloading a file shard: {downloadResult}.");
             return(false);
         }
     }
     return(true);
 }
        /// <summary>
        /// Initializes this file database manifest
        /// </summary>
        private static FileDatabaseManifest GetOrCreateFileDatabaseManifest(
            BackblazeB2AuthorizationSession authorizationSession,
            Config config
            )
        {
            if (SharedFileDatabaseManifest == null)
            {
                lock (SharedFileDatabaseManifestLock)
                {
                    if (SharedFileDatabaseManifest == null)
                    {
                        // Get just the file names on the server
                        ListFilesAction listFilesAction = ListFilesAction.CreateListFileActionForFileNames(
                            authorizationSession,
                            config.BucketID,
                            true
                            );
                        BackblazeB2ActionResult <BackblazeB2ListFilesResult> listFilesActionResult = listFilesAction.Execute();
                        if (listFilesActionResult.HasErrors)
                        {
                            throw new FailedToGetListOfFilesOnB2Exception
                                  {
                                      BackblazeErrorDetails = listFilesActionResult.Errors,
                                  };
                        }
                        FileResult fileDatabaseManifestFileResult = listFilesActionResult.Result.Files
                                                                    .Where(f => f.FileName.Equals(RemoteFileDatabaseManifestName, StringComparison.Ordinal))
                                                                    .SingleOrDefault();
                        if (fileDatabaseManifestFileResult == null)
                        {
                            SharedFileDatabaseManifest = new FileDatabaseManifest
                            {
                                DataFormatVersionNumber = CurrentDatabaseDataFormatVersion,
                                Files = new Database.File[0]
                            };
                        }
                        else
                        {
                            using (MemoryStream outputStream = new MemoryStream())
                                using (DownloadFileAction manifestFileDownloadAction = new DownloadFileAction(
                                           authorizationSession,
                                           outputStream,
                                           fileDatabaseManifestFileResult.FileID
                                           ))
                                {
                                    BackblazeB2ActionResult <BackblazeB2DownloadFileResult> manifestResultOption =
                                        manifestFileDownloadAction.Execute();
                                    if (manifestResultOption.HasResult)
                                    {
                                        // Now, read string from manifest
                                        outputStream.Flush();
                                        SharedFileDatabaseManifest = DeserializeManifest(
                                            outputStream.ToArray(),
                                            config
                                            );
                                    }
                                    else
                                    {
                                        SharedFileDatabaseManifest = new FileDatabaseManifest
                                        {
                                            DataFormatVersionNumber = CurrentDatabaseDataFormatVersion,
                                            Files = new Database.File[0]
                                        };
                                    }
                                }
                        }
                    }
                }
            }

            return(SharedFileDatabaseManifest);
        }