Changeset View
Changeset View
Standalone View
Standalone View
src/lint/ArcanistLintPatcher.php
| Show All 36 Lines | public function writePatchToDisk() { | ||||
| do { | do { | ||||
| $lint = $path.'.linted'.($ii++); | $lint = $path.'.linted'.($ii++); | ||||
| } while (file_exists($lint)); | } while (file_exists($lint)); | ||||
| // Copy existing file to preserve permissions. 'chmod --reference' is not | // Copy existing file to preserve permissions. 'chmod --reference' is not | ||||
| // supported under OSX. | // supported under OSX. | ||||
| if (Filesystem::pathExists($path)) { | if (Filesystem::pathExists($path)) { | ||||
| // This path may not exist if we're generating a new file. | // This path may not exist if we're generating a new file. | ||||
| execx('cp -p %s %s', $path, $lint); | Filesystem::copyFile($path, $lint); | ||||
| } | } | ||||
| Filesystem::writeFile($lint, $data); | Filesystem::writeFile($lint, $data); | ||||
| list($err) = exec_manual('mv -f %s %s', $lint, $path); | try { | ||||
| if ($err) { | Filesystem::rename($lint, $path); | ||||
| } catch (FilesystemException $e) { | |||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| "Unable to overwrite path '%s', patched version was left at '%s'.", | "Unable to overwrite path '%s', patched version was left at '%s'.", | ||||
| $path, | $path, | ||||
| $lint)); | $lint)); | ||||
| } | } | ||||
| foreach ($this->applyMessages as $message) { | foreach ($this->applyMessages as $message) { | ||||
| ▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines | |||||