Skip to content

Commit 9b3350e

Browse files
committed
Handle disk full errors
1 parent 678a376 commit 9b3350e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/briefly.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ defmodule Briefly do
2424
"""
2525
@spec create(create_opts) ::
2626
{:ok, binary}
27+
| {:no_space, binary}
2728
| {:too_many_attempts, binary, pos_integer}
2829
| {:no_tmp, [binary]}
2930
def create(opts \\ []) do

lib/briefly/entry.ex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,14 @@ defmodule Briefly.Entry do
173173
:ets.insert(@path_table, {self(), path})
174174
{:ok, path}
175175

176+
{:error, :enospc} ->
177+
{:no_space, path}
178+
176179
{:error, reason} when reason in [:eexist, :eacces] ->
177180
open(options, tmp, attempts + 1)
181+
182+
error ->
183+
error
178184
end
179185
end
180186

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

195+
{:error, :enospc} ->
196+
{:no_space, path}
197+
189198
{:error, reason} when reason in [:eexist, :eacces] ->
190199
open(options, tmp, attempts + 1)
200+
201+
error ->
202+
error
191203
end
192204
end
193205

0 commit comments

Comments
 (0)