mirror of
https://github.com/usememos/memos.git
synced 2025-12-16 21:59:25 +08:00
chore: fix resource path
This commit is contained in:
parent
f5461264c5
commit
074e7cf71a
1 changed files with 3 additions and 1 deletions
|
|
@ -271,6 +271,7 @@ func SaveResourceBlob(ctx context.Context, s *store.Store, create *store.Resourc
|
||||||
internalPath = replacePathTemplate(internalPath, create.Filename)
|
internalPath = replacePathTemplate(internalPath, create.Filename)
|
||||||
internalPath = filepath.ToSlash(internalPath)
|
internalPath = filepath.ToSlash(internalPath)
|
||||||
|
|
||||||
|
// Ensure the directory exists.
|
||||||
osPath := filepath.FromSlash(internalPath)
|
osPath := filepath.FromSlash(internalPath)
|
||||||
if !filepath.IsAbs(osPath) {
|
if !filepath.IsAbs(osPath) {
|
||||||
osPath = filepath.Join(s.Profile.Data, osPath)
|
osPath = filepath.Join(s.Profile.Data, osPath)
|
||||||
|
|
@ -285,7 +286,8 @@ func SaveResourceBlob(ctx context.Context, s *store.Store, create *store.Resourc
|
||||||
}
|
}
|
||||||
defer dst.Close()
|
defer dst.Close()
|
||||||
|
|
||||||
if err := os.WriteFile(dir, create.Blob, 0644); err != nil {
|
// Write the blob to the file.
|
||||||
|
if err := os.WriteFile(osPath, create.Blob, 0644); err != nil {
|
||||||
return errors.Wrap(err, "Failed to write file")
|
return errors.Wrap(err, "Failed to write file")
|
||||||
}
|
}
|
||||||
create.InternalPath = internalPath
|
create.InternalPath = internalPath
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue