Implement Rust-owned adaptive Android password navigation (#96)
This commit is contained in:
1 parent
36e5f55283
commit
8c9341f214
26 files changed
+1553
-16
No files matched your search
@@ -391,6 +391,60 @@ impl Repository {
|
||||
Ok(EncryptedEntry(bytes))
|
||||
}
|
||||
|
||||
/// A non-secret object revision; navigation never opens encrypted contents.
|
||||
pub(crate) fn navigation_revision(
|
||||
&self,
|
||||
path: &Path,
|
||||
entry: bool,
|
||||
) -> Result<String, RepositoryError> {
|
||||
let relative = if entry {
|
||||
EntryPath::parse(path)?.encrypted_relative_path()
|
||||
} else {
|
||||
DirectoryPath::parse(path)?.as_path().to_owned()
|
||||
};
|
||||
let metadata = if relative.as_os_str().is_empty() {
|
||||
self.root
|
||||
.dir_metadata()
|
||||
.map_err(|error| io_error("inspect repository", path, error))?
|
||||
} else {
|
||||
let parent = self.open_directory(relative.parent().unwrap_or(Path::new("")))?;
|
||||
child_metadata(
|
||||
&parent,
|
||||
relative.file_name().expect("relative object"),
|
||||
&relative,
|
||||
)?
|
||||
.ok_or_else(|| RepositoryError::NotFound {
|
||||
path: relative.clone(),
|
||||
})?
|
||||
};
|
||||
if entry {
|
||||
require_regular_file(metadata.clone(), &relative)?;
|
||||
} else {
|
||||
require_directory(metadata.clone(), &relative)?;
|
||||
}
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use cap_std::fs::MetadataExt;
|
||||
Ok(format!(
|
||||
"{}:{}:{}:{}:{}:{}:{}",
|
||||
metadata.dev(),
|
||||
metadata.ino(),
|
||||
metadata.len(),
|
||||
metadata.mtime(),
|
||||
metadata.mtime_nsec(),
|
||||
if entry { metadata.ctime() } else { 0 },
|
||||
if entry { metadata.ctime_nsec() } else { 0 }
|
||||
))
|
||||
}
|
||||
#[cfg(not(unix))]
|
||||
Ok(format!(
|
||||
"{}:{:?}:{:?}",
|
||||
metadata.len(),
|
||||
metadata.modified(),
|
||||
metadata.created()
|
||||
))
|
||||
}
|
||||
|
||||
pub(crate) fn read_policy_file(
|
||||
&self,
|
||||
directory: &DirectoryPath,
|
||||
|
||||
Reference in new issue
Block a user