Be careful when creating subkey links
- When creating the link from a subkey to a primary key, if the subkey is also a primary key, don't create the link. - Consider two primary keys, A and B. A can add B as a subkey. In this case, B shouldn't link to A, but be a normal file containing B.
This commit is contained in:
parent
dfbb4ec553
commit
4ba0afe5a3
|
@ -260,6 +260,17 @@ impl Database for Filesystem {
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
if link.exists() {
|
||||
match link.symlink_metadata() {
|
||||
Ok(ref meta) if meta.file_type().is_file() => {
|
||||
// If a key is a subkey and a primary key, prefer
|
||||
// the primary.
|
||||
return Ok(());
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
symlink(&target, ensure_parent(&link)?)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue