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:
Neal H. Walfield 2019-02-22 20:39:51 +01:00
parent dfbb4ec553
commit 4ba0afe5a3
1 changed files with 11 additions and 0 deletions

View File

@ -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)?)
}