Skip to content

Commit

Permalink
Merge pull request #42 from infinityoneframework/fail-full
Browse files Browse the repository at this point in the history
Handle disk full errors
  • Loading branch information
benwilson512 authored Sep 25, 2023
2 parents 678a376 + 9b3350e commit 51dfe7f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/briefly.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ defmodule Briefly do
"""
@spec create(create_opts) ::
{:ok, binary}
| {:no_space, binary}
| {:too_many_attempts, binary, pos_integer}
| {:no_tmp, [binary]}
def create(opts \\ []) do
Expand Down
12 changes: 12 additions & 0 deletions lib/briefly/entry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,14 @@ defmodule Briefly.Entry do
:ets.insert(@path_table, {self(), path})
{:ok, path}

{:error, :enospc} ->
{:no_space, path}

{:error, reason} when reason in [:eexist, :eacces] ->
open(options, tmp, attempts + 1)

error ->
error
end
end

Expand All @@ -186,8 +192,14 @@ defmodule Briefly.Entry do
:ets.insert(@path_table, {self(), path})
{:ok, path}

{:error, :enospc} ->
{:no_space, path}

{:error, reason} when reason in [:eexist, :eacces] ->
open(options, tmp, attempts + 1)

error ->
error
end
end

Expand Down

0 comments on commit 51dfe7f

Please sign in to comment.