- Timestamp:
- Sep 19, 2021, 2:55:12 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/msgstore_fs.go
r558 r591 17 17 const fsMessageStoreMaxTries = 100 18 18 19 var escapeFilename = strings.NewReplacer("/", "-", "\\", "-") 19 func escapeFilename(unsafe string) (safe string) { 20 if unsafe == "." { 21 return "-" 22 } else if unsafe == ".." { 23 return "--" 24 } else { 25 return strings.NewReplacer("/", "-", "\\", "-").Replace(unsafe) 26 } 27 } 20 28 21 29 type date struct { … … 70 78 func newFSMessageStore(root, username string) *fsMessageStore { 71 79 return &fsMessageStore{ 72 root: filepath.Join(root, escapeFilename .Replace(username)),80 root: filepath.Join(root, escapeFilename(username)), 73 81 files: make(map[string]*os.File), 74 82 } … … 78 86 year, month, day := t.Date() 79 87 filename := fmt.Sprintf("%04d-%02d-%02d.log", year, month, day) 80 return filepath.Join(ms.root, escapeFilename .Replace(network.GetName()), escapeFilename.Replace(entity), filename)88 return filepath.Join(ms.root, escapeFilename(network.GetName()), escapeFilename(entity), filename) 81 89 } 82 90 … … 440 448 441 449 func (ms *fsMessageStore) ListTargets(network *network, start, end time.Time, limit int) ([]chatHistoryTarget, error) { 442 rootPath := filepath.Join(ms.root, escapeFilename .Replace(network.GetName()))450 rootPath := filepath.Join(ms.root, escapeFilename(network.GetName())) 443 451 root, err := os.Open(rootPath) 444 452 if err != nil {
Note:
See TracChangeset
for help on using the changeset viewer.