-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
164 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use std::path::Path; | ||
|
||
use crate::error::OxenError; | ||
use crate::model::{Commit, CommitEntry, LocalRepository, MerkleHash}; | ||
use crate::util; | ||
|
||
// TODO: probably need to pass a data node here instead of a hash to get the metadata | ||
pub fn restore_file( | ||
repo: &LocalRepository, | ||
hash: &MerkleHash, | ||
dst_path: &Path, | ||
) -> Result<(), OxenError> { | ||
let version_path = util::fs::version_path_from_hash(repo, hash); | ||
if !version_path.exists() { | ||
return Err(OxenError::basic_str(&format!( | ||
"Source file not found in versions directory: {:?}", | ||
version_path | ||
))); | ||
} | ||
|
||
let working_path = repo.path.join(dst_path); | ||
if let Some(parent) = dst_path.parent() { | ||
util::fs::create_dir_all(parent)?; | ||
} | ||
|
||
util::fs::copy(version_path, working_path.clone())?; | ||
// TODO: set file metadata | ||
// Previous version used: | ||
// CommitEntryWriter::set_file_timestamps(repo, path, entry, files_db)?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters