Пример #1
0
        /// <summary>
        /// Processes an updated scanned file into the database.
        /// </summary>
        /// <param name="fileLookup">File index lookup result</param>
        /// <param name="fileInfo">FileInfo details</param>
        private async Task ProcessUpdatedFileAsync(BackupFileLookup fileLookup, FileInfo fileInfo)
        {
            Logger.WriteTraceMessage(string.Format("Updated File: {0}", fileInfo.FullName));

            // update the file metadata (size, last written, blocks)
            fileLookup.File.LastModified    = fileInfo.LastWriteTime;
            fileLookup.File.FileSizeBytes   = fileInfo.Length;
            fileLookup.File.TotalFileBlocks = fileLookup.File.CalculateTotalFileBlocks(Constants.Transfers.TransferBlockSizeBytes);

            // commit the updated file metadata.
            // this resets the backup copy state.
            await Database.ResetBackupFileStateAsync(fileLookup.File).ConfigureAwait(false);
        }
Пример #2
0
        /// <summary>
        /// Processes an existing scanned file into the database.
        /// </summary>
        /// <param name="fileLookup">File index lookup result</param>
        /// <param name="fileInfo">FileInfo details</param>
        private async Task ProcessExistingFileAsync(BackupFileLookup fileLookup, FileInfo fileInfo)
        {
            // do not write trace messages for unchanged files
            // it becomes too noisy in the logs.

            if (fileLookup.File.OverallState == FileStatus.ProviderError || fileLookup.File.WasDeleted.HasValue)
            {
                Logger.WriteTraceMessage(string.Format("Reset File: {0}", fileInfo.FullName));

                // existing file but in a failed state or deleted state.
                // since we have rescanned we should reset the failed state to allow for a retry.
                await Database.ResetBackupFileStateAsync(fileLookup.File).ConfigureAwait(false);
            }
            else
            {
                // existing file
                // should update the last checked flag
                await Database.SetBackupFileLastScannedAsync(fileLookup.File.FileID).ConfigureAwait(false);
            }
        }