@@ -237,4 +237,42 @@ public function testCopyBetweenJails() {
237237 $ this ->assertEquals ('2 ' , $ this ->instance ->file_get_contents ('b/target/sub/2.txt ' ));
238238 $ this ->assertEquals ('3 ' , $ this ->instance ->file_get_contents ('b/target/sub/3.txt ' ));
239239 }
240+
241+ public function testCopyPreservesPermissions () {
242+ $ cache = $ this ->instance ->getCache ();
243+
244+ $ this ->instance ->file_put_contents ('test.txt ' , 'foo ' );
245+ $ this ->assertTrue ($ cache ->inCache ('test.txt ' ));
246+
247+ $ cache ->update ($ cache ->getId ('test.txt ' ), ['permissions ' => \OCP \Constants::PERMISSION_READ ]);
248+ $ this ->assertEquals (\OCP \Constants::PERMISSION_READ , $ this ->instance ->getPermissions ('test.txt ' ));
249+
250+ $ this ->assertTrue ($ this ->instance ->copy ('test.txt ' , 'new.txt ' ));
251+
252+ $ this ->assertTrue ($ cache ->inCache ('new.txt ' ));
253+ $ this ->assertEquals (\OCP \Constants::PERMISSION_READ , $ this ->instance ->getPermissions ('new.txt ' ));
254+ }
255+
256+ /**
257+ * Test that copying files will drop permissions like local storage does
258+ * TODO: Drop this and fix local storage
259+ */
260+ public function testCopyGrantsPermissions () {
261+ $ config ['objectstore ' ] = $ this ->objectStorage ;
262+ $ config ['handleCopiesAsOwned ' ] = true ;
263+ $ instance = new ObjectStoreStorageOverwrite ($ config );
264+
265+ $ cache = $ instance ->getCache ();
266+
267+ $ instance ->file_put_contents ('test.txt ' , 'foo ' );
268+ $ this ->assertTrue ($ cache ->inCache ('test.txt ' ));
269+
270+ $ cache ->update ($ cache ->getId ('test.txt ' ), ['permissions ' => \OCP \Constants::PERMISSION_READ ]);
271+ $ this ->assertEquals (\OCP \Constants::PERMISSION_READ , $ instance ->getPermissions ('test.txt ' ));
272+
273+ $ this ->assertTrue ($ instance ->copy ('test.txt ' , 'new.txt ' ));
274+
275+ $ this ->assertTrue ($ cache ->inCache ('new.txt ' ));
276+ $ this ->assertEquals (\OCP \Constants::PERMISSION_ALL , $ instance ->getPermissions ('new.txt ' ));
277+ }
240278}
0 commit comments