File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -290,8 +290,6 @@ impl<B: IoProvider> LocalCache<B> {
290
290
}
291
291
}
292
292
293
- // XXX MAKE READONLY -- the ideal approach depends on unstable APIs
294
-
295
293
temp_dest. path ( ) . to_owned ( )
296
294
} ;
297
295
@@ -308,6 +306,18 @@ impl<B: IoProvider> LocalCache<B> {
308
306
return OpenResult :: Err ( e. into ( ) ) ;
309
307
}
310
308
309
+ // Make the file readonly once it's at its final path.
310
+ // XXX: It would be better to set these using the already-open file handle owned by the
311
+ // tempfile, but mkstemp doesn't give us access.
312
+ let mut perms = match fs:: metadata ( & final_path) {
313
+ Ok ( p) => p,
314
+ Err ( e) => return OpenResult :: Err ( e. into ( ) ) ,
315
+ } . permissions ( ) ;
316
+ perms. set_readonly ( true ) ;
317
+ if let Err ( e) = fs:: set_permissions ( & final_path, perms) {
318
+ return OpenResult :: Err ( e. into ( ) ) ;
319
+ }
320
+
311
321
// And finally add a record of this file to our manifest. Note that
312
322
// we're opening and closing this file every time we load a new file;
313
323
// not so efficient, but whatever.
You can’t perform that action at this time.
0 commit comments