droxi 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/droxi.gemspec +1 -1
- data/lib/droxi.rb +1 -1
- data/lib/droxi/commands.rb +29 -23
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41024246faf2e570c6f96a0c2cfa77af7a871cbb
|
4
|
+
data.tar.gz: 9a516974414a11c3427e81590aa77d92a43e68d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13d4714c04d56e274c6dc50a7612bb51714c956503faf91a2b83b68d054221ffbb576455d44ad7568ee2a44998bb4f724cbed135108740e303d113ae2490a334
|
7
|
+
data.tar.gz: a91221075eb67995cb8a38578a4a030531e7028e86ed1346fae2570d28c56cb0b4e153e9cf51c8592c66408dd038bd2963213445bddfd4089d1fd824972a52de
|
data/droxi.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'droxi'
|
3
3
|
s.version = IO.read('lib/droxi.rb')[/VERSION = '(.+)'/, 1]
|
4
|
-
s.date = '2014-
|
4
|
+
s.date = '2014-12-17'
|
5
5
|
s.summary = 'ftp-like command-line interface to Dropbox'
|
6
6
|
s.description = "A command-line Dropbox interface inspired by GNU \
|
7
7
|
coreutils, GNU ftp, and lftp. Features include smart tab \
|
data/lib/droxi.rb
CHANGED
data/lib/droxi/commands.rb
CHANGED
@@ -357,14 +357,21 @@ module Commands
|
|
357
357
|
|
358
358
|
# Upload a local file.
|
359
359
|
PUT = Command.new(
|
360
|
-
'put [-f] [-O REMOTE_DIR] LOCAL_FILE...',
|
360
|
+
'put [-f] [-q] [-O REMOTE_DIR] [-t COUNT] LOCAL_FILE...',
|
361
361
|
"Upload local files to the remote working directory. If a remote file of \
|
362
362
|
the same name already exists, Dropbox will rename the upload unless the \
|
363
363
|
the -f option is given, in which case the remote file will be \
|
364
364
|
overwritten. If the -O option is given, the files will be uploaded to \
|
365
|
-
the given directory instead of the current directory.
|
365
|
+
the given directory instead of the current directory. The -q option \
|
366
|
+
prevents progress from being printed. The -t option specifies the \
|
367
|
+
number of tries in case of error. The default is 5; -t 0 will retry \
|
368
|
+
infinitely.",
|
366
369
|
lambda do |client, state, args|
|
367
|
-
flags = extract_flags(PUT.usage, args,
|
370
|
+
flags = extract_flags(PUT.usage, args,
|
371
|
+
'-f' => 0,
|
372
|
+
'-q' => 0,
|
373
|
+
'-O' => 1,
|
374
|
+
'-t' => 1)
|
368
375
|
|
369
376
|
dest_index = flags.find_index('-O')
|
370
377
|
dest_path = nil
|
@@ -378,6 +385,9 @@ module Commands
|
|
378
385
|
end
|
379
386
|
end
|
380
387
|
|
388
|
+
tries_index = flags.find_index('-t')
|
389
|
+
tries = tries_index ? flags[tries_index + 1].to_i : 5
|
390
|
+
|
381
391
|
args.each do |arg|
|
382
392
|
to_path = state.resolve_path(File.basename(arg))
|
383
393
|
|
@@ -390,7 +400,8 @@ module Commands
|
|
390
400
|
|
391
401
|
# Chunked upload if file is more than 1M.
|
392
402
|
if file.size > 1024 * 1024
|
393
|
-
data = chunked_upload(client, to_path, file
|
403
|
+
data = chunked_upload(client, to_path, file,
|
404
|
+
flags.include?('-q'), tries)
|
394
405
|
else
|
395
406
|
data = client.put_file(to_path, file)
|
396
407
|
end
|
@@ -659,17 +670,6 @@ module Commands
|
|
659
670
|
(state.pwd = File.dirname(state.pwd)) until state.metadata(state.pwd)
|
660
671
|
end
|
661
672
|
|
662
|
-
# def self.extract_flags(@usage, cmd, args, valid_flags)
|
663
|
-
# tokens = args.take_while { |s| s[/^-\w+$/] }
|
664
|
-
# args.shift(tokens.size)
|
665
|
-
|
666
|
-
# # Process compound flags like -rf into -r, -f.
|
667
|
-
# flags = tokens.join.chars.uniq.drop(1).map { |c| "-#{c}" }
|
668
|
-
# invalid_flags = flags.reject { |f| valid_flags[f[1]] }
|
669
|
-
# invalid_flags.each { |f| warn "#{cmd}: #{f}: invalid option" }
|
670
|
-
# flags
|
671
|
-
# end
|
672
|
-
|
673
673
|
# Removes flags (e.g. -f) from the +Array+ and returns an +Array+ of the
|
674
674
|
# removed flags. Prints warnings if the flags are not in the given +String+
|
675
675
|
# of valid flags (e.g. '-rf').
|
@@ -701,29 +701,35 @@ module Commands
|
|
701
701
|
end
|
702
702
|
|
703
703
|
# Attempts to upload a file to the server in chunks, displaying progress.
|
704
|
-
def self.chunked_upload(client, to_path, file)
|
704
|
+
def self.chunked_upload(client, to_path, file, quiet, tries)
|
705
705
|
uploader = DropboxClient::ChunkedUploader.new(client, file, file.size)
|
706
|
-
thread = Thread.new { monitor_upload(uploader, to_path) }
|
707
|
-
|
706
|
+
thread = quiet ? nil : Thread.new { monitor_upload(uploader, to_path) }
|
707
|
+
tries = -1 if tries == 0
|
708
|
+
loop_upload(uploader, thread, tries)
|
708
709
|
data = uploader.finish(to_path)
|
709
|
-
thread
|
710
|
-
|
710
|
+
if thread
|
711
|
+
thread.join
|
712
|
+
print "\r" + (' ' * (18 + to_path.rpartition('/')[2].size)) + "\r"
|
713
|
+
end
|
711
714
|
data
|
712
715
|
end
|
713
716
|
|
714
717
|
# Continuously try to upload until successful or interrupted.
|
715
|
-
|
716
|
-
|
718
|
+
# rubocop:disable Style/MethodLength
|
719
|
+
def self.loop_upload(uploader, monitor_thread, tries)
|
720
|
+
while tries != 0 && uploader.offset < uploader.total_size
|
717
721
|
begin
|
718
722
|
uploader.upload(1024 * 1024)
|
719
723
|
rescue DropboxError => error
|
720
724
|
puts "\n" + error.to_s
|
725
|
+
--tries
|
721
726
|
end
|
722
727
|
end
|
723
728
|
rescue Interrupt => error
|
724
|
-
monitor_thread.kill
|
729
|
+
monitor_thread.kill if monitor_thread
|
725
730
|
raise error
|
726
731
|
end
|
732
|
+
# rubocop:enable Style/MethodLength
|
727
733
|
|
728
734
|
# Displays real-time progress for the a being uploaded.
|
729
735
|
def self.monitor_upload(uploader, to_path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: droxi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mulcahy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dropbox-sdk
|