diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2015-02-23 18:16:55 -0800 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2015-02-23 18:16:55 -0800 |
commit | ef43e934de266b49dec9373cb6c281c0ee7c67dc (patch) | |
tree | 6f2847e47bb49bc515fd8d99b64ba0d8ec3c38c3 /lib | |
parent | Remove dead code. (diff) | |
download | backend-ef43e934de266b49dec9373cb6c281c0ee7c67dc.tar.gz backend-ef43e934de266b49dec9373cb6c281c0ee7c67dc.tar.bz2 backend-ef43e934de266b49dec9373cb6c281c0ee7c67dc.zip |
Improve delete code paths.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/storage.rb | 4 | ||||
-rw-r--r-- | lib/utils.rb | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/storage.rb b/lib/storage.rb index 8ab2d4e..68de268 100644 --- a/lib/storage.rb +++ b/lib/storage.rb @@ -141,6 +141,10 @@ module Ag::Storage resolve_by_field(list, :raw_filename, filename) end + def resolve_hash(list, hash = nil) + resolve_by_field(list, :_id, hash) + end + def store(list, message, filename) content = get_content(message, filename) diff --git a/lib/utils.rb b/lib/utils.rb index 38349e0..b9156cd 100644 --- a/lib/utils.rb +++ b/lib/utils.rb @@ -33,6 +33,12 @@ module Ag id = Ag::Storage.resolve_message_id($options.name, $options.dir) when :file id = Ag::Storage.resolve_filename($options.name, $options.dir) + when :hash + id = Ag::Storage.resolve_hash($options.name, $options.dir) + when :dir + abort 'Cannot perform resolve a directory to a message id' + when nil + abort 'Cannot resolve a nil id' end id |