Skip to content

Commit 5177cdc

Browse files
committed
Add logging and skip to sincedb write in case of permissions snafu
1 parent d4cf673 commit 5177cdc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/filewatch/helper.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,13 @@ def write_atomically(file_name)
3838
return return_val if old_stat.nil?
3939

4040
# Set correct uid/gid on new file
41-
File.chown(old_stat.uid, old_stat.gid, file_name) if old_stat
42-
41+
if old_stat
42+
begin
43+
File.chown(old_stat.uid, old_stat.gid, file_name)
44+
rescue Errno::EPERM => e
45+
logger.error("sincedb_write: #{file_name} error:", :old_stat => old_stat, :exception => e.class, :message => e.message)
46+
end
47+
end
4348
return_val
4449
end
4550

0 commit comments

Comments
 (0)