public static Tuple <DateTime, long, long>[] GetBrokenFilesetsFromRemote(string backendurl, BasicResults result, Database.LocalListBrokenFilesDatabase db, System.Data.IDbTransaction transaction, Options options, out List <Database.RemoteVolumeEntry> missing)
        {
            missing = null;
            var brokensets = db.GetBrokenFilesets(options.Time, options.Version, transaction).ToArray();

            if (brokensets.Length == 0)
            {
                if (db.RepairInProgress)
                {
                    throw new UserInformationException("Cannot continue because the database is marked as being under repair, but does not have broken files.", "CannotListOnDatabaseInRepair");
                }

                Logging.Log.WriteInformationMessage(LOGTAG, "NoBrokenFilesetsInDatabase", "No broken filesets found in database, checking for missing remote files");

                using (var backend = new BackendManager(backendurl, options, result.BackendWriter, db))
                {
                    var remotestate = FilelistProcessor.RemoteListAnalysis(backend, options, db, result.BackendWriter, null);
                    if (!remotestate.ParsedVolumes.Any())
                    {
                        throw new UserInformationException("No remote volumes were found, refusing purge", "CannotPurgeWithNoRemoteVolumes");
                    }

                    missing = remotestate.MissingVolumes.ToList();
                    if (missing.Count == 0)
                    {
                        Logging.Log.WriteInformationMessage(LOGTAG, "NoMissingFilesFound", "Skipping operation because no files were found to be missing, and no filesets were recorded as broken.");
                        return(null);
                    }

                    // Mark all volumes as disposable
                    foreach (var f in missing)
                    {
                        db.UpdateRemoteVolume(f.Name, RemoteVolumeState.Deleting, f.Size, f.Hash, transaction);
                    }

                    Logging.Log.WriteInformationMessage(LOGTAG, "MarkedRemoteFilesForDeletion", "Marked {0} remote files for deletion", missing.Count);

                    // Drop all content from tables
                    db.RemoveMissingBlocks(missing.Select(x => x.Name), transaction);
                }
                brokensets = db.GetBrokenFilesets(options.Time, options.Version, transaction).ToArray();
            }

            return(brokensets);
        }
Beispiel #2
0
 internal void SetResult(BasicResults result)
 {
     m_result = result;
 }