mirror of
https://github.com/mattermost/focalboard.git
synced 2024-11-30 08:36:54 +02:00
Fixup for old file path
This commit is contained in:
parent
679a689d3f
commit
41ccd7651c
@ -4,6 +4,8 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
@ -32,5 +34,25 @@ func (a *App) GetFilePath(workspaceID, rootID, filename string) string {
|
||||
folderPath := a.config.FilesPath
|
||||
rootPath := filepath.Join(folderPath, workspaceID, rootID)
|
||||
|
||||
return filepath.Join(rootPath, filename)
|
||||
filePath := filepath.Join(rootPath, filename)
|
||||
|
||||
// FIXUP: Check the deprecated old location
|
||||
if workspaceID == "0" && !fileExists(filePath) {
|
||||
oldFilePath := filepath.Join(folderPath, filename)
|
||||
if fileExists(oldFilePath) {
|
||||
err := os.Rename(oldFilePath, filePath)
|
||||
if err != nil {
|
||||
log.Printf("ERROR moving old file from '%s' to '%s'", oldFilePath, filePath)
|
||||
} else {
|
||||
log.Printf("Moved old file from '%s' to '%s'", oldFilePath, filePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return filePath
|
||||
}
|
||||
|
||||
func fileExists(path string) bool {
|
||||
_, err := os.Stat(path)
|
||||
return !os.IsNotExist(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user