jgm-cloudlib 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/cloudlib +13 -16
- data/cloudlib.gemspec +1 -1
- metadata +1 -1
data/bin/cloudlib
CHANGED
@@ -189,27 +189,24 @@ if ARGV.length >= 1
|
|
189
189
|
exit 0
|
190
190
|
end
|
191
191
|
if ARGV[0] == "dump"
|
192
|
-
path = ARGV[1] || "."
|
192
|
+
path = ARGV[1] || ask("Dump to which directory? ", String) { |q| q.default = "."; q.echo = true }
|
193
193
|
new_entries = 0
|
194
194
|
dummy, entries = Cloudlib::Entry.query("", nil)
|
195
195
|
total_size = entries.inject(0) {|accum, e| accum + e.attributes['size'][0].to_i}
|
196
|
-
printf("Total size is %.2f megabytes
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
new_entries += 1
|
208
|
-
STDERR.puts entry.to_s
|
209
|
-
end
|
196
|
+
printf("Total size is %.2f megabytes.\n", (total_size / (1024.0 * 1024.0)))
|
197
|
+
open("#{path}/#{ENV['CLOUDLIB_LIBRARY_NAME']}.db", 'w') do |file|
|
198
|
+
STDERR.puts "Backing up metadata..."
|
199
|
+
file.write(YAML.dump(entries))
|
200
|
+
end
|
201
|
+
STDERR.puts "Backing up files:"
|
202
|
+
entries.each do |entry|
|
203
|
+
if not File.exists?("#{path}/#{entry.name}")
|
204
|
+
entry.download("#{path}/#{entry.name}")
|
205
|
+
new_entries += 1
|
206
|
+
STDERR.puts entry.to_s
|
210
207
|
end
|
211
|
-
STDERR.puts "Backed up metadata and #{new_entries} new files."
|
212
208
|
end
|
209
|
+
STDERR.puts "Backed up metadata and #{new_entries} new files."
|
213
210
|
exit 0
|
214
211
|
end
|
215
212
|
if ARGV[0] == "restore"
|
data/cloudlib.gemspec
CHANGED