diff --git a/lib/file_store/base_store.rb b/lib/file_store/base_store.rb index 7e984a65288..275e78dff73 100644 --- a/lib/file_store/base_store.rb +++ b/lib/file_store/base_store.rb @@ -71,8 +71,12 @@ module FileStore def purge_tombstone(grace_period) end + def get_depth_for(id) + [0, Math.log(id / 1_000.0, 16).ceil].max + end + def get_path_for(type, id, sha, extension) - depth = [0, Math.log(id / 1_000.0, 16).ceil].max + depth = get_depth_for(id) tree = File.join(*sha[0, depth].split(""), "") "#{type}/#{depth + 1}X/#{tree}#{sha}#{extension}" end diff --git a/spec/components/cooked_post_processor_spec.rb b/spec/components/cooked_post_processor_spec.rb index e775d535424..1134278e227 100644 --- a/spec/components/cooked_post_processor_spec.rb +++ b/spec/components/cooked_post_processor_spec.rb @@ -114,6 +114,8 @@ describe CookedPostProcessor do # hmmm this should be done in a cleaner way OptimizedImage.expects(:resize).returns(true) + + FileStore::BaseStore.any_instance.expects(:get_depth_for).returns(0) end it "generates overlay information" do @@ -141,6 +143,7 @@ describe CookedPostProcessor do # hmmm this should be done in a cleaner way OptimizedImage.expects(:resize).returns(true) + FileStore::BaseStore.any_instance.expects(:get_depth_for).returns(0) end it "generates overlay information" do