@@ -333,7 +333,10 @@ public function fopen(string $path, string $mode) {
333333 $ fh = fopen ('sftpwrite:// ' . trim ($ absPath , '/ ' ), 'w ' , false , $ context );
334334 if ($ fh ) {
335335 $ fh = CallbackWrapper::wrap ($ fh , null , null , function () use ($ path ): void {
336- $ this ->knownMTimes ->set ($ path , time ());
336+ $ mtime = time ();
337+ $ this ->knownMTimes ->set ($ path , $ mtime );
338+ $ this ->getConnection ()->touch ($ this ->absPath ($ path ), $ mtime , $ mtime );
339+ $ this ->getConnection ()->clearStatCache ();
337340 });
338341 }
339342 return $ fh ;
@@ -429,6 +432,11 @@ public function constructUrl(string $path): string {
429432 public function file_put_contents (string $ path , mixed $ data ): int |float |false {
430433 /** @psalm-suppress InternalMethod */
431434 $ result = $ this ->getConnection ()->put ($ this ->absPath ($ path ), $ data );
435+ $ mtime = time ();
436+ $ this ->knownMTimes ->set ($ path , $ mtime );
437+ $ this ->getConnection ()->touch ($ this ->absPath ($ path ), $ mtime , $ mtime );
438+ $ this ->getConnection ()->clearStatCache ();
439+
432440 if ($ result ) {
433441 return strlen ($ data );
434442 } else {
@@ -448,6 +456,11 @@ public function writeStream(string $path, $stream, ?int $size = null): int {
448456 /** @psalm-suppress InternalMethod */
449457 $ result = $ this ->getConnection ()->put ($ this ->absPath ($ path ), $ stream );
450458 fclose ($ stream );
459+ $ mtime = time ();
460+ $ this ->knownMTimes ->set ($ path , $ mtime );
461+ $ this ->getConnection ()->touch ($ this ->absPath ($ path ), $ mtime , $ mtime );
462+ $ this ->getConnection ()->clearStatCache ();
463+
451464 if ($ result ) {
452465 if ($ size === null ) {
453466 throw new \Exception ('Failed to get written size from sftp storage wrapper ' );
0 commit comments