Skip to content

Commit

Permalink
set mode of cache files to 0666 & ~umask, related to #147
Browse files Browse the repository at this point in the history
  • Loading branch information
toy committed Apr 10, 2017
1 parent 7d4ece5 commit dc0d44e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/image_optim/cache.rb
Expand Up @@ -34,6 +34,7 @@ def fetch(original)
if optimized
tmp = FSPath.temp_file_path(digest, @cache_dir)
FileUtils.mv(optimized, tmp)
tmp.chmod(0o666 & ~File.umask)
tmp.rename(cached)
cached_path = CachePath.convert(cached)

Expand Down
3 changes: 3 additions & 0 deletions spec/image_optim/cache_spec.rb
Expand Up @@ -72,6 +72,9 @@
expect(FileUtils).to receive(:mv).with(optimized, tmp_file)
expect(tmp_file).to receive(:rename).with(cached)

allow(File).to receive(:umask).and_return(0o024)
expect(tmp_file).to receive(:chmod).with(0o642)

expect(cache.fetch(original){ optimized }).to eq(cached)
end

Expand Down

0 comments on commit dc0d44e

Please sign in to comment.