refactor: unify data directory structure
Unify user data directory from fragmented layout to consistent nested format: - Move WebDAV from: data/files/<username> → data/<username>/files/ - Move CalDAV from: data/<username>/cal-<name> → data/<username>/calendars/<name> - Move CardDAV from: data/<username>/card-<name> → data/<username>/addressbooks/<name> Changes: - internal/store/store.go: Update collectionPath() to map collection names - internal/store/migrate.go: Add idempotent Migrate() method - internal/store/migrate_test.go: Comprehensive migration tests - internal/webdav/handler.go: Use new unified path structure - cmd/server/main.go: Auto-run migration on startup - tools/nidusctl/main.go: Add migrate subcommand - Update tests to verify new structure URL endpoints unchanged - only on-disk structure modified. All tests pass.
This commit is contained in:
+29
-10
@@ -61,6 +61,8 @@ func run(args []string) int {
|
||||
return runCalendar(dbase, st, rest[1:])
|
||||
case "addressbook", "card":
|
||||
return runAddressBook(dbase, st, rest[1:])
|
||||
case "migrate":
|
||||
return runMigrate(st, rest[1:])
|
||||
case "help", "-h", "--help":
|
||||
usage()
|
||||
return 0
|
||||
@@ -88,20 +90,23 @@ Usage:
|
||||
nidusctl [-config config.yaml] calendar unshare <owner> <calendar> <user>
|
||||
nidusctl [-config config.yaml] calendar shares <owner> <calendar>
|
||||
|
||||
nidusctl [-config config.yaml] addressbook create <owner> <book>
|
||||
nidusctl [-config config.yaml] addressbook delete <owner> <book>
|
||||
nidusctl [-config config.yaml] addressbook list <owner>
|
||||
nidusctl [-config config.yaml] addressbook share <owner> <book> <user> <read|write>
|
||||
nidusctl [-config config.yaml] addressbook unshare <owner> <book> <user>
|
||||
nidusctl [-config config.yaml] addressbook shares <owner> <book>
|
||||
nidusctl [-config config.yaml] addressbook create <owner> <book>
|
||||
nidusctl [-config config.yaml] addressbook delete <owner> <book>
|
||||
nidusctl [-config config.yaml] addressbook list <owner>
|
||||
nidusctl [-config config.yaml] addressbook share <owner> <book> <user> <read|write>
|
||||
nidusctl [-config config.yaml] addressbook unshare <owner> <book> <user>
|
||||
nidusctl [-config config.yaml] addressbook shares <owner> <book>
|
||||
|
||||
nidusctl [-config config.yaml] migrate [--verbose]
|
||||
|
||||
Examples:
|
||||
nidusctl user create alice --display-name "Alice Smith" --email alice@example.com
|
||||
nidusctl calendar create alice work
|
||||
nidusctl calendar share alice work bob write
|
||||
nidusctl calendar shares alice work
|
||||
nidusctl calendar unshare alice work bob
|
||||
`)
|
||||
nidusctl calendar share alice work bob write
|
||||
nidusctl calendar shares alice work
|
||||
nidusctl calendar unshare alice work bob
|
||||
nidusctl migrate
|
||||
`)
|
||||
}
|
||||
|
||||
// newFlagSet creates a flag.FlagSet configured for subcommand parsing
|
||||
@@ -359,6 +364,20 @@ func runAddressBook(dbase *db.DB, st *store.Store, args []string) int {
|
||||
}
|
||||
}
|
||||
|
||||
func runMigrate(st *store.Store, args []string) int {
|
||||
fs := newFlagSet("migrate")
|
||||
if err := fs.Parse(args); err != nil {
|
||||
return 2
|
||||
}
|
||||
|
||||
if err := st.Migrate(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "migration failed: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
fmt.Println("Migration completed successfully")
|
||||
return 0
|
||||
}
|
||||
|
||||
// warnIfUnknownUser reports (without failing) if username is not a
|
||||
// registered user — the share is still recorded, since a user could be
|
||||
// created afterwards.
|
||||
|
||||
Reference in New Issue
Block a user