From 4bb2831857cd275ba66b33df92a5ca28efe3ee13 Mon Sep 17 00:00:00 2001 From: HouXiaoxuan Date: Sat, 23 Dec 2023 20:52:44 +0800 Subject: [PATCH] =?UTF-8?q?fix=20restore=E6=96=87=E4=BB=B6=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E6=96=B0=E5=BB=BA=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/store.rs b/src/store.rs index 6871ba0..c0b0a0e 100644 --- a/src/store.rs +++ b/src/store.rs @@ -36,6 +36,10 @@ impl Store { /// 将hash对应的文件内容(主要是blob)还原到file pub fn restore_to_file(&self, hash: &Hash, file: &PathBuf) { let content = self.load(hash); + // 保证文件层次存在 + let mut parent = file.clone(); + parent.pop(); + std::fs::create_dir_all(parent).unwrap(); std::fs::write(file, content).unwrap(); }