Skip to content

Commit 84e2772

Browse files
Stéphane BourStephaneBourtaylorotwell
authored
[10.x] Filesystem : can lock file on append of content (#49262)
* [10.x] Can lock file on append of content * Update facade docblocks * Update Filesystem.php --------- Co-authored-by: StephaneBour <[email protected]> Co-authored-by: Taylor Otwell <[email protected]>
1 parent 7d26bfb commit 84e2772

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Illuminate/Filesystem/Filesystem.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,12 @@ public function prepend($path, $data)
268268
*
269269
* @param string $path
270270
* @param string $data
271+
* @param bool $lock
271272
* @return int
272273
*/
273-
public function append($path, $data)
274+
public function append($path, $data, $lock = false)
274275
{
275-
return file_put_contents($path, $data, FILE_APPEND);
276+
return file_put_contents($path, $data, FILE_APPEND | ($lock ? LOCK_EX : 0));
276277
}
277278

278279
/**

src/Illuminate/Support/Facades/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* @method static void replace(string $path, string $content, int|null $mode = null)
1717
* @method static void replaceInFile(array|string $search, array|string $replace, string $path)
1818
* @method static int prepend(string $path, string $data)
19-
* @method static int append(string $path, string $data)
19+
* @method static int append(string $path, string $data, bool $lock = false)
2020
* @method static mixed chmod(string $path, int|null $mode = null)
2121
* @method static bool delete(string|array $paths)
2222
* @method static bool move(string $path, string $target)

0 commit comments

Comments
 (0)