コード例 #1
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;
    }
コード例 #2
0
        public void CmdCopyRemote()
        {
            var acct = _getAcct();

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

            var cr = new BackupLib.commands.CopyRemote
            {
                account     = acct
                , cache     = acct.service.fileCache
                , container = cont
                , pathRoot  = this.testRoot
                , key       = this.pubKey
            };

            cr.run();
        }
コード例 #3
0
ファイル: UnitTest2.cs プロジェクト: cptnalf/b2_autopush
        public void CopyRemote()
        {
            var accts = _makeSvc();
            var acct  = accts.accounts[0];

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

            conts.run();

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

            var cr = new BackupLib.commands.CopyRemote
            {
                account     = acct
                , cache     = accts.filecache
                , container = cont
                , pathRoot  = @"c:\tmp\photos"
                , key       = @"c:\tmp\id_rsa_1_pub"
            };

            cr.run();
        }