mirror of
https://github.com/Dvorinka/excalidraw-full.git
synced 2026-07-28 23:23:47 +00:00
文件系统的存储方式
This commit is contained in:
@@ -9,3 +9,4 @@ node_modules
|
||||
*.env
|
||||
*/build/*
|
||||
*.db
|
||||
data/
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ type (
|
||||
UserID string `json:"-"` // Not exposed in JSON responses, used internally.
|
||||
Name string `json:"name"`
|
||||
Thumbnail string `json:"thumbnail,omitempty"`
|
||||
Data []byte `json:"-"` // The full canvas data, not included in list views.
|
||||
Data []byte `json:"data,omitempty"` // The full canvas data, not included in list views.
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
excalidraw:
|
||||
image: ghcr.io/betterandbetterii/excalidraw-full-linuxdo:linux-do
|
||||
ports:
|
||||
- "3002:3002"
|
||||
volumes:
|
||||
- ./data:/root/data
|
||||
- ./excalidraw.db:/root/excalidraw.db
|
||||
env_file:
|
||||
- .env
|
||||
@@ -92,6 +92,12 @@ func (s *fsStore) List(ctx context.Context, userID string) ([]*core.Canvas, erro
|
||||
for _, file := range files {
|
||||
if !file.IsDir() {
|
||||
filePath := filepath.Join(userPath, file.Name())
|
||||
fileInfo, err := file.Info()
|
||||
if err != nil {
|
||||
log.WithError(err).Warnf("Failed to get file info for %s, skipping", file.Name())
|
||||
continue
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
log.WithError(err).Warnf("Failed to read canvas file %s, skipping", file.Name())
|
||||
@@ -105,7 +111,9 @@ func (s *fsStore) List(ctx context.Context, userID string) ([]*core.Canvas, erro
|
||||
}
|
||||
|
||||
// For list view, we don't need the full data blob.
|
||||
// Also ensure we populate metadata from the filesystem.
|
||||
canvas.Data = nil
|
||||
canvas.UpdatedAt = fileInfo.ModTime()
|
||||
canvases = append(canvases, &canvas)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user