Skip to content

Commit

Permalink
Merge branch 'delete-skipped-files' of github.com:dmarkow/arc into fe…
Browse files Browse the repository at this point in the history
…ature/arc-pull-286
  • Loading branch information
achempion committed Aug 30, 2019
2 parents 0aff862 + 0993e96 commit cf9d3e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion lib/waffle/actions/delete.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ defmodule Waffle.Actions.Delete do
end

defp delete_version(definition, version, {file, scope}) do
definition.__storage.delete(definition, version, {file, scope})
conversion = definition.transform(version, {file, scope})
if conversion == :skip do
:ok
else
definition.__storage.delete(definition, version, {file, scope})
end
end
end
9 changes: 6 additions & 3 deletions test/storage/local_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ defmodule WaffleTest.Storage.Local do


defmodule DummyDefinition do
use Waffle.Actions.Store
use Waffle.Definition.Storage
use Waffle.Actions.Url
use Waffle.Definition

@acl :public_read
def transform(:thumb, _), do: {:convert, "-strip -thumbnail 10x10"}
Expand Down Expand Up @@ -44,6 +42,11 @@ defmodule WaffleTest.Storage.Local do
refute File.exists?("waffletest/uploads/1/thumb-image.png")
end

test "deleting when there's a skipped version" do
DummyDefinition.store(@img)
assert :ok = DummyDefinition.delete(@img)
end

test "save binary" do
Waffle.Storage.Local.put(DummyDefinition, :original, {Waffle.File.new(%{binary: "binary", filename: "binary.png"}), nil})
assert true == File.exists?("waffletest/uploads/binary.png")
Expand Down

0 comments on commit cf9d3e1

Please sign in to comment.