folderSubpathOf returns the note's directory relative to its top-level folder root ("" when it sits at the folder root). Carried along on archive/trash moves so the reverse move restores the subfolder. Mirrors folderSubpathOf in apps/desktop/src/main/vault.ts.
(abs string)
| 1569 | // archive/trash moves so the reverse move restores the subfolder. |
| 1570 | // Mirrors folderSubpathOf in apps/desktop/src/main/vault.ts. |
| 1571 | func (v *Vault) folderSubpathOf(abs string) string { |
| 1572 | folder, ok := v.folderOf(abs) |
| 1573 | if !ok { |
| 1574 | return "" |
| 1575 | } |
| 1576 | sourceRoot, err := v.folderRoot(folder) |
| 1577 | if err != nil { |
| 1578 | return "" |
| 1579 | } |
| 1580 | relDir, err := filepath.Rel(sourceRoot, filepath.Dir(abs)) |
| 1581 | if err != nil || relDir == "." || strings.HasPrefix(relDir, "..") || filepath.IsAbs(relDir) { |
| 1582 | return "" |
| 1583 | } |
| 1584 | return relDir |
| 1585 | } |
| 1586 | |
| 1587 | func (v *Vault) moveBetweenFolders(rel string, target NoteFolder) (NoteMeta, error) { |
| 1588 | v.mu.Lock() |
no test coverage detected