@@ -117,7 +117,7 @@ protected function tearDown(): void {
117
117
\OC_User::setUserId ($ this ->user );
118
118
foreach ($ this ->storages as $ storage ) {
119
119
$ cache = $ storage ->getCache ();
120
- $ ids = $ cache ->getAll ();
120
+ $ cache ->getAll ();
121
121
$ cache ->clear ();
122
122
}
123
123
@@ -1884,7 +1884,7 @@ function () use ($view, $lockedPath, &$lockTypeDuring, $operation) {
1884
1884
$ lockTypeDuring = $ this ->getFileLockType ($ view , $ lockedPath );
1885
1885
1886
1886
if ($ operation === 'fopen ' ) {
1887
- return \fopen ('data://text/plain,test ' , 'r ' );
1887
+ return \fopen ('data://text/plain,test ' , 'rb ' );
1888
1888
}
1889
1889
return true ;
1890
1890
}
@@ -2750,4 +2750,27 @@ public function testDeleteNonShareFolder($shareFolder, $deleteFolder) {
2750
2750
$ view ->mkdir ($ deleteFolder );
2751
2751
$ this ->assertTrue ($ view ->rmdir ($ deleteFolder ));
2752
2752
}
2753
+
2754
+ public function testCacheSizeUpdatedWhenEmptyingFile (): void {
2755
+ $ storage1 = $ this ->getTestStorage ();
2756
+ Filesystem::mount ($ storage1 , [], '/ ' );
2757
+
2758
+ $ rootView = new View ('' );
2759
+
2760
+ # test with string as $data
2761
+ $ rootView ->file_put_contents ('welcome.txt ' , '1234567890 ' );
2762
+ $ this ->assertEquals (10 , $ rootView ->filesize ('welcome.txt ' ));
2763
+
2764
+ $ rootView ->file_put_contents ('welcome.txt ' , '' );
2765
+ $ this ->assertEquals (0 , $ rootView ->filesize ('welcome.txt ' ));
2766
+
2767
+ # test with resource as $data
2768
+ $ stream = fopen ('data://text/plain,1234567890 ' , 'rb ' );
2769
+ $ rootView ->file_put_contents ('welcome.txt ' , $ stream );
2770
+ $ this ->assertEquals (10 , $ rootView ->filesize ('welcome.txt ' ));
2771
+
2772
+ $ stream = fopen ('data://text/plain, ' , 'rb ' );
2773
+ $ rootView ->file_put_contents ('welcome.txt ' , '' );
2774
+ $ this ->assertEquals (0 , $ rootView ->filesize ('welcome.txt ' ));
2775
+ }
2753
2776
}
0 commit comments