filestorage 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/filestorage/local.rb +19 -1
- data/lib/filestorage/version.rb +1 -1
- 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: 2abf484dfc5af8e0ef647937ed42157988a2e0d7
|
4
|
+
data.tar.gz: 29de042d162e5d27dbd487db7d3f6f7c13cdd424
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cd06b97c672d866c85052ae557de92aac191afd8589f55edb0e0fa5c128d26c1c289e4536974b4c33d1edf08830e8925be8388fffcbac8b10b744f8e5713ae8
|
7
|
+
data.tar.gz: 1e48f071b52fe5f0ab184ae21a7e448b17f9bafb8febb4409fd6f69dac9d7b35fe50e4469b418e62e7577ddb4bc85e43c6253e96a7cae0f310170fe98005a430
|
data/lib/filestorage/local.rb
CHANGED
@@ -37,10 +37,11 @@ module Filestorage
|
|
37
37
|
File.open(fullpath, "rb")
|
38
38
|
end
|
39
39
|
|
40
|
-
def delete(path)
|
40
|
+
def delete(path, delete_dir: false)
|
41
41
|
fullpath = @base_dir + path
|
42
42
|
raise NotExist.new("Not exist #{path}") unless File.exist?(fullpath)
|
43
43
|
FileUtils.rm(fullpath)
|
44
|
+
sweep(fullpath.parent) if delete_dir
|
44
45
|
path
|
45
46
|
end
|
46
47
|
|
@@ -58,6 +59,23 @@ module Filestorage
|
|
58
59
|
files
|
59
60
|
end
|
60
61
|
|
62
|
+
private
|
63
|
+
|
64
|
+
def sweep(path)
|
65
|
+
paths(path).reverse.each do |p|
|
66
|
+
FileUtils.rmdir(p) if p.children.empty?
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def paths(path)
|
71
|
+
p = []
|
72
|
+
until path.to_s == @base_dir.to_s
|
73
|
+
p << path
|
74
|
+
path = path.parent
|
75
|
+
end
|
76
|
+
p.reverse
|
77
|
+
end
|
78
|
+
|
61
79
|
end # of class Local
|
62
80
|
|
63
81
|
end # of module LocalFilestorage
|
data/lib/filestorage/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filestorage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- takatoh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|