コード例 #1
0
ファイル: CleanupFilesTask.cs プロジェクト: pcloayza/sensenet
        /// <summary>
        /// This method deletes orphaned rows from the database physically.
        /// </summary>
        private async Task CleanupFilesDeleteRowsAsync(CancellationToken cancellationToken)
        {
            var deleteCount = 0;

            try
            {
                SnTrace.Database.Write(SnMaintenance.TracePrefix + "Cleanup files: deleting rows...");

                // keep deleting orphaned binary rows while there are any
                while (await BlobStorage.CleanupFilesAsync(cancellationToken).ConfigureAwait(false))
                {
                    deleteCount++;
                }

                if (deleteCount > 0)
                {
                    SnLog.WriteInformation($"{deleteCount} orphaned rows were deleted from the binary table during cleanup.",
                                           EventId.RepositoryRuntime);
                }
            }
            catch (Exception ex)
            {
                SnLog.WriteWarning("Error in file cleanup background process. " + ex, EventId.RepositoryRuntime);
            }
        }