Method: File.write
- Defined in:
- lib/extension.rb
.write(path, string, *options, mode: nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/extension.rb', line 26 def File.write(path, string, *, mode: nil) return super if mode dirpath = File.dirname(path) temp_path = File.join(dirpath, SecureRandom.hex(15)) if File.extname(path) == ".yaml" && File.basename(dirpath) != Downloader::SECTION_SAVE_DIR_NAME backup = "#{path}.backup" end res = super(temp_path, string, *) if backup super(backup, string, *) end File.rename(temp_path, path) res end |