blob: 803970ba9f15b35fc0312a0a1d714ebf953efb08 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
package main
import (
"os"
"path/filepath"
)
func Rename(source, target string) {
source, err := filepath.Abs(source)
if err != nil {
panic("Unable to get abspath of " + source)
}
target, err = filepath.Abs(target)
if err != nil {
panic("Unable to get abspath of " + target)
}
if !DocCollection.Contain(source) {
panic("Database doesn't contain " + source)
}
if err := os.Rename(source, target); err != nil {
panic(err)
}
doc := DocCollection[source]
for backlink := range doc.backlinks {
DocCollection[backlink].UpdateLinks(source, target)
}
}
|