Beispiel #1
0
        private void ChangeBackup(CBOptions opts)
        {
            string curpath = CurrentNode.Path;
            string backuphash;

            if (opts.Backup == null)
            {
                if (opts.Offset == 0)
                {
                    throw new ChangeBackupException("Must set either or both backup or offset.");
                }
                backuphash = BackupHash;
            }
            else
            {
                backuphash = opts.Backup;
            }
            var targetbackuphashandrecord = BCore.DefaultDstDependencies[BackupDst].Backups.GetBackupHashAndRecord(new BackupSetReference(BackupSet, false, false, false), backuphash, opts.Offset);

            BackupHash = targetbackuphashandrecord.Item1;
            BackupCore.BackupRecord backuprecord = targetbackuphashandrecord.Item2;
            BackupTree = BackupCore.MetadataNode.Load(BCore.DefaultDstDependencies[BackupDst].Blobs, backuprecord.MetadataTreeHash);
            BackupCore.MetadataNode?curnode = BackupTree.GetDirectory(curpath);
            if (curnode != null)
            {
                CurrentNode = curnode;
            }
            else
            {
                CurrentNode = BackupTree;
            }
            Console.WriteLine("Switching to backup {0}: \"{1}\"", BackupHash.Substring(0, 6), backuprecord.BackupMessage);
        }
Beispiel #2
0
 private void ChangeDirectory(CDOptions opts)
 {
     BackupCore.MetadataNode?dir;
     try
     {
         if (opts.Directory.StartsWith(Path.DirectorySeparatorChar.ToString()))
         {
             dir = BackupTree.GetDirectory(opts.Directory);
         }
         else
         {
             dir = BackupTree.GetDirectory(Path.Combine(CurrentNode.Path, opts.Directory));
         }
     }
     catch (Exception)
     {
         dir = null;
     }
     if (dir == null)
     {
         Console.WriteLine("Cannot find directory specified");
         return;
     }
     CurrentNode = dir;
 }