unstable: initial tags
This commit is contained in:
parent
2e71b60248
commit
b3b62af3a4
28 changed files with 503 additions and 91 deletions
|
|
@ -49,24 +49,35 @@ func (db *DB) DeleteID(path string) error {
|
|||
return db.store.Delete(idPrefix + path)
|
||||
}
|
||||
|
||||
func (db *DB) NewFile(id, path string) (err error) {
|
||||
func (db *DB) NewFile(id, path string, tags []string) (err error) {
|
||||
err = db.store.Set(idPrefix+path, id)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = db.store.Set(pathPrefix+id, path)
|
||||
return
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return db.SetTag(path, tags)
|
||||
}
|
||||
|
||||
func (db *DB) MoveFile(op, np string) error {
|
||||
func (db *DB) MoveFile(op, np string) (err error) {
|
||||
if !db.IsIndexed(op) {
|
||||
return nil
|
||||
}
|
||||
id, err := db.DeleteFile(op)
|
||||
if err != nil {
|
||||
return err
|
||||
return
|
||||
}
|
||||
return db.NewFile(id, np)
|
||||
tags, err := db.GetTag(op)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = db.NewFile(id, np, tags)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return db.UnsetTag(op)
|
||||
}
|
||||
|
||||
func (db *DB) DeleteFile(path string) (id string, err error) {
|
||||
|
|
@ -81,6 +92,10 @@ func (db *DB) DeleteFile(path string) (id string, err error) {
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = db.UnsetTag(path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = db.DeletePath(id)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue