mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 07:49:11 +03:00
remotefilelog: set proper file permissions on closed mutable packs.
Summary: The python version of the mutable packs set the permission to read-only after writing them, while the rust version keeps them writeable. Let's make the rust one more consistent. Reviewed By: markbt Differential Revision: D13573572 fbshipit-source-id: 61256994562aa09058a88a7935c16dfd7ddf9d18
This commit is contained in:
parent
603daf671b
commit
ce16778656
@ -506,6 +506,12 @@ pub mod tests {
|
||||
{
|
||||
let mut file = File::open(&pack_path).unwrap();
|
||||
file.read_to_end(&mut buf).unwrap();
|
||||
|
||||
// After being closed the datapacks are read-only. Since the next part of the test
|
||||
// corrupt it, let's make it writable.
|
||||
let mut perms = file.metadata().unwrap().permissions();
|
||||
perms.set_readonly(false);
|
||||
file.set_permissions(perms).unwrap();
|
||||
}
|
||||
buf[0] = 0;
|
||||
OpenOptions::new()
|
||||
|
@ -76,6 +76,12 @@ impl MutableDataPack {
|
||||
let data_filepath = base_filepath.with_extension("datapack");
|
||||
let index_filepath = base_filepath.with_extension("dataidx");
|
||||
|
||||
let mut perms = self.data_file.as_file().metadata()?.permissions();
|
||||
perms.set_readonly(true);
|
||||
|
||||
self.data_file.as_file().set_permissions(perms.clone())?;
|
||||
index_file.as_file().set_permissions(perms)?;
|
||||
|
||||
self.data_file.persist(&data_filepath)?;
|
||||
index_file.persist(&index_filepath)?;
|
||||
Ok(base_filepath)
|
||||
|
@ -109,6 +109,12 @@ impl MutableHistoryPack {
|
||||
let data_filepath = base_filepath.with_extension("histpack");
|
||||
let index_filepath = base_filepath.with_extension("histidx");
|
||||
|
||||
let mut perms = data_file.as_file().metadata()?.permissions();
|
||||
perms.set_readonly(true);
|
||||
|
||||
data_file.as_file().set_permissions(perms.clone())?;
|
||||
index_file.as_file().set_permissions(perms)?;
|
||||
|
||||
data_file.persist(&data_filepath)?;
|
||||
index_file.persist(&index_filepath)?;
|
||||
Ok(base_filepath)
|
||||
|
Loading…
Reference in New Issue
Block a user