コード例 #1
0
        public void CmdCopyLocal()
        {
            var acct = _getAcct();

            var cont = acct.service.fileCache.getContainers(acct.id).FirstOrDefault();

            BUCommon.FreezeFile rmt = null;
            if (cont.files.Count > 0)
            {
                rmt = cont.files[0];
            }

            Assert.IsNotNull(rmt);
            Assert.IsNotNull(rmt.fileID);

            var cl = new BackupLib.commands.CopyLocal
            {
                account    = acct
                , key      = privateKey
                , destPath = testDest
                , cont     = cont
                , maxTasks = 1
                , noAction = true
                , filterre = rmt.path
            };

            System.IO.Directory.CreateDirectory(cl.destPath);
            cl.run();
        }
コード例 #2
0
ファイル: CopyCmd.cs プロジェクト: cptnalf/b2_autopush
    public override int run(BUCommon.AccountList accounts)
    {
      var src = _parseLoc(accounts, _opts.source);
      var dest = _parseLoc(accounts, _opts.dest);

      if (src.cont == null) { return _err("ERROR - source is unknown: {0}", _opts.source); }
      if (dest.cont == null) { return _err("ERROR - dest is unknown: {0}", _opts.dest); }

      if (src.acct == null && dest.acct == null)
        { return _err("ERROR - use copy instead of this program (both are local)."); }
      
      if (src.acct != null && dest.acct != null)
        { return _err("ERROR - remote to remote copying is not yet supported."); }

      /* these options should be mutually exclusive. */
      if (dest.acct != null)
        {
          var crm = new BackupLib.commands.CopyRemote
              {
                  cache=accounts.filecache
                  , account=dest.acct
                  , container=dest.cont
                  , pathRoot=src.cont.id

                  , progress= _printDiff

                  , fileRE=_opts.filterRE
                  , key=_opts.key
                  , noAction=_opts.dryrun
              };
          crm.run();
        }

      if (src.acct != null && !string.IsNullOrWhiteSpace(_opts.filterRE))
        {
          var cl = new BackupLib.commands.CopyLocal 
            { 
              account=src.acct
              , destPath=dest.cont.id
              , filterre = _opts.filterRE
              , key=_opts.key
              , noAction=_opts.dryrun
              , progress= _printDiff
              , errors = _printExcept
            };
          cl.run();
        }
      
      return 0;
    }
コード例 #3
0
ファイル: UnitTest2.cs プロジェクト: cptnalf/b2_autopush
        public void CopyLocal()
        {
            var accts = _makeSvc();
            var acct  = accts.accounts[0];

            var conts = new BackupLib.commands.Containers {
                account = acct, cache = accts.filecache
            };

            conts.run();

            BUCommon.FreezeFile rmt = null;

            var cont = accts.filecache.containers[0];

            if (cont.files.Count > 0)
            {
                rmt = cont.files[0];
            }

            Assert.That(rmt, Is.Not.Null);
            Assert.That(rmt.fileID, Is.Not.Null);

            var cl = new BackupLib.commands.CopyLocal
            {
                account    = acct
                , cont     = cont
                , noAction = true
                , filterre = rmt.path
                , key      = @"c:\tmp\id_rsa_1"
                , destPath = @"c:\tmp\photos1"
            };

            System.IO.Directory.CreateDirectory(cl.destPath);
            cl.run();
        }