chore: use consistent relative paths for resources (#2683)

- always store resources with a relative path with forward slashes, which will be transformed as needed when the file is accessed

- fix an issue with thumbnail generation on Windows

- add several validations for local storage setting

- improve front-end error feedback when changing local storage

- add migrations to make existing resource paths relative (not needed, but improves database consistency)
This commit is contained in:
Lincoln Nogueira
2023-12-28 20:49:55 -03:00
committed by GitHub
parent ea87a1dc0c
commit 411e807dcc
8 changed files with 112 additions and 14 deletions

View File

@@ -95,7 +95,11 @@ func (s *Store) DeleteResource(ctx context.Context, delete *DeleteResource) erro
// Delete the local file.
if resource.InternalPath != "" {
_ = os.Remove(resource.InternalPath)
resourcePath := filepath.FromSlash(resource.InternalPath)
if !filepath.IsAbs(resourcePath) {
resourcePath = filepath.Join(s.Profile.Data, resourcePath)
}
_ = os.Remove(resourcePath)
}
// Delete the thumbnail.
if util.HasPrefixes(resource.Type, "image/png", "image/jpeg") {