worktree: Fix privacy check for singleton files (#21861)
Closes #20676 Release Notes: - Fixed private files not being redacted when not part of a larger worktree
This commit is contained in:
parent
59afc27f03
commit
cc97e682d5
3 changed files with 41 additions and 20 deletions
|
@ -409,24 +409,11 @@ impl Worktree {
|
|||
abs_path
|
||||
.file_name()
|
||||
.map_or(String::new(), |f| f.to_string_lossy().to_string()),
|
||||
abs_path,
|
||||
abs_path.clone(),
|
||||
),
|
||||
root_file_handle,
|
||||
};
|
||||
|
||||
if let Some(metadata) = metadata {
|
||||
snapshot.insert_entry(
|
||||
Entry::new(
|
||||
Arc::from(Path::new("")),
|
||||
&metadata,
|
||||
&next_entry_id,
|
||||
snapshot.root_char_bag,
|
||||
None,
|
||||
),
|
||||
fs.as_ref(),
|
||||
);
|
||||
}
|
||||
|
||||
let worktree_id = snapshot.id();
|
||||
let settings_location = Some(SettingsLocation {
|
||||
worktree_id,
|
||||
|
@ -445,10 +432,26 @@ impl Worktree {
|
|||
})
|
||||
.detach();
|
||||
|
||||
let share_private_files = false;
|
||||
if let Some(metadata) = metadata {
|
||||
let mut entry = Entry::new(
|
||||
Arc::from(Path::new("")),
|
||||
&metadata,
|
||||
&next_entry_id,
|
||||
snapshot.root_char_bag,
|
||||
None,
|
||||
);
|
||||
if !metadata.is_dir {
|
||||
entry.is_private = !share_private_files
|
||||
&& settings.is_path_private(abs_path.file_name().unwrap().as_ref());
|
||||
}
|
||||
snapshot.insert_entry(entry, fs.as_ref());
|
||||
}
|
||||
|
||||
let (scan_requests_tx, scan_requests_rx) = channel::unbounded();
|
||||
let (path_prefixes_to_scan_tx, path_prefixes_to_scan_rx) = channel::unbounded();
|
||||
let mut worktree = LocalWorktree {
|
||||
share_private_files: false,
|
||||
share_private_files,
|
||||
next_entry_id,
|
||||
snapshot,
|
||||
is_scanning: watch::channel_with(true),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue