mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-05 07:26:36 +08:00
chore(lint): unify formatting on golangci-lint fmt (gofumpt), uncap issue reporting, fix gofumpt drift
- make format 现在与 code-check 使用同一格式化器(golangci-lint fmt),消除 goimports -local 与 gofumpt 的格式拉锯 - .golangci.yml 关闭默认 50/3 截断,完整上报所有问题(只增强不弱化) - 全库 gofumpt 规范化(203 files, 纯格式无行为变更)
This commit is contained in:
+1
-1
@@ -5,13 +5,13 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
uploadstorage "Wavelet/plugins/domain/upload/storage"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
uploadstorage "Wavelet/plugins/domain/upload/storage"
|
||||
)
|
||||
|
||||
|
||||
+4
-7
@@ -4,15 +4,14 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"Wavelet/pkg/cache/ram"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"Wavelet/pkg/cache/ram"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -21,9 +20,7 @@ const (
|
||||
uploadMetaInvalidationChan = "upload:meta_invalidation"
|
||||
)
|
||||
|
||||
var (
|
||||
uploadMetaRAM = ram.MustNew[uint64, models.Upload](ram.Options{MaximumSize: uploadMetaRAMMaximumSize})
|
||||
)
|
||||
var uploadMetaRAM = ram.MustNew[uint64, models.Upload](ram.Options{MaximumSize: uploadMetaRAMMaximumSize})
|
||||
|
||||
func uploadMetaRedisKey(id uint64) string {
|
||||
return fmt.Sprintf("upload:meta:%d", id)
|
||||
|
||||
+3
-4
@@ -4,14 +4,13 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"Wavelet/pkg/testhelper"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"Wavelet/pkg/testhelper"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -5,6 +5,13 @@
|
||||
package filesrv
|
||||
|
||||
import (
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/logger"
|
||||
"Wavelet/pkg/response"
|
||||
"Wavelet/plugins/domain/upload/cache"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"Wavelet/plugins/domain/upload/util"
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
@@ -15,16 +22,11 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"Wavelet/core/contracts"
|
||||
pkgcache "Wavelet/pkg/cache/disk"
|
||||
"Wavelet/pkg/logger"
|
||||
"Wavelet/pkg/response"
|
||||
|
||||
pkgutil "Wavelet/pkg/util"
|
||||
"Wavelet/plugins/domain/upload/cache"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
|
||||
uploadstorage "Wavelet/plugins/domain/upload/storage"
|
||||
"Wavelet/plugins/domain/upload/util"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"golang.org/x/sync/singleflight"
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
package filesrv
|
||||
|
||||
import (
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/response"
|
||||
"Wavelet/pkg/testhelper"
|
||||
"Wavelet/plugins/domain/upload/cache"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
@@ -23,12 +29,6 @@ import (
|
||||
"github.com/gin-contrib/sessions/cookie"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/response"
|
||||
"Wavelet/pkg/testhelper"
|
||||
"Wavelet/plugins/domain/upload/cache"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
uploadutil "Wavelet/plugins/domain/upload/util"
|
||||
)
|
||||
|
||||
@@ -45,7 +45,7 @@ func (s *localTestStorageService) Put(_ context.Context, key string, body io.Rea
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
path := filepath.Join(s.root, key)
|
||||
_ = os.MkdirAll(filepath.Dir(path), 0755)
|
||||
_ = os.MkdirAll(filepath.Dir(path), 0o755)
|
||||
f, err := os.Create(path)
|
||||
if err != nil {
|
||||
return contracts.StoragePutResult{}, err
|
||||
@@ -140,10 +140,10 @@ func TestServeFileByIDAccessControl(t *testing.T) {
|
||||
AccessMode: 1,
|
||||
}
|
||||
|
||||
if err := os.WriteFile(filepath.Join(tempDir, "avatar.png"), []byte("image"), 0644); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(tempDir, "avatar.png"), []byte("image"), 0o644); err != nil {
|
||||
t.Fatalf("failed to write avatar file: %v", err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(tempDir, "doc.pdf"), []byte("bytes"), 0644); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(tempDir, "doc.pdf"), []byte("bytes"), 0o644); err != nil {
|
||||
t.Fatalf("failed to write attachment file: %v", err)
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ func TestServeFileByIDImageCompression(t *testing.T) {
|
||||
}
|
||||
|
||||
filePath := filepath.Join(tempDir, "test_image.png")
|
||||
if err := os.WriteFile(filePath, pngBuf.Bytes(), 0644); err != nil {
|
||||
if err := os.WriteFile(filePath, pngBuf.Bytes(), 0o644); err != nil {
|
||||
t.Fatalf("failed to write test png: %v", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,6 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/response"
|
||||
"Wavelet/pkg/util"
|
||||
@@ -16,6 +11,11 @@ import (
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/repository"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
uploadstorage "Wavelet/plugins/domain/upload/storage"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,16 +4,15 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
)
|
||||
|
||||
func TestGetDistinctUploadTypes(t *testing.T) {
|
||||
|
||||
@@ -4,15 +4,14 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"Wavelet/plugins/domain/upload/ingest"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/repository"
|
||||
"context"
|
||||
"errors"
|
||||
"sort"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"Wavelet/plugins/domain/upload/ingest"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/repository"
|
||||
)
|
||||
|
||||
func listUploadFiles(ctx context.Context, filter repository.UploadListFilter) (int64, []models.Upload, error) {
|
||||
|
||||
@@ -5,6 +5,14 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/logger"
|
||||
"Wavelet/pkg/response"
|
||||
"Wavelet/plugins/domain/upload/filesrv"
|
||||
"Wavelet/plugins/domain/upload/ingest"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"Wavelet/plugins/domain/upload/util"
|
||||
"archive/zip"
|
||||
"bufio"
|
||||
"bytes"
|
||||
@@ -24,16 +32,9 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/logger"
|
||||
"Wavelet/pkg/response"
|
||||
pkgutil "Wavelet/pkg/util"
|
||||
"Wavelet/plugins/domain/upload/filesrv"
|
||||
"Wavelet/plugins/domain/upload/ingest"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
|
||||
uploadstorage "Wavelet/plugins/domain/upload/storage"
|
||||
"Wavelet/plugins/domain/upload/util"
|
||||
)
|
||||
|
||||
type batchDownloadRequest struct {
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/response"
|
||||
"Wavelet/pkg/util"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"archive/zip"
|
||||
"bytes"
|
||||
"context"
|
||||
@@ -22,11 +27,6 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/response"
|
||||
"Wavelet/pkg/util"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
uploadstats "Wavelet/plugins/domain/upload/stats"
|
||||
)
|
||||
|
||||
@@ -112,8 +112,8 @@ func (s *handlerTestStorage) Put(_ context.Context, key string, body io.Reader,
|
||||
*s.putCount++
|
||||
}
|
||||
if strings.HasPrefix(key, "uploads/") {
|
||||
_ = os.MkdirAll(filepath.Dir(key), 0755)
|
||||
_ = os.WriteFile(key, data, 0644)
|
||||
_ = os.MkdirAll(filepath.Dir(key), 0o755)
|
||||
_ = os.WriteFile(key, data, 0o644)
|
||||
}
|
||||
return contracts.StoragePutResult{Key: key, Bucket: "test-bucket"}, nil
|
||||
}
|
||||
@@ -367,11 +367,11 @@ func TestDownloadFile(t *testing.T) {
|
||||
}
|
||||
|
||||
// Create local file
|
||||
err := os.MkdirAll("uploads", 0755)
|
||||
err := os.MkdirAll("uploads", 0o755)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create directory: %v", err)
|
||||
}
|
||||
err = os.WriteFile(localUpload.FilePath, []byte("hello download"), 0644)
|
||||
err = os.WriteFile(localUpload.FilePath, []byte("hello download"), 0o644)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to write file: %v", err)
|
||||
}
|
||||
@@ -563,14 +563,14 @@ func TestBatchDownloadFiles(t *testing.T) {
|
||||
router := setupTestRouter(authUser)
|
||||
|
||||
// Create and write files locally
|
||||
err := os.MkdirAll("uploads", 0755)
|
||||
err := os.MkdirAll("uploads", 0o755)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create local dir: %v", err)
|
||||
}
|
||||
|
||||
_ = os.WriteFile("uploads/f1.txt", []byte("file1 content"), 0644)
|
||||
_ = os.WriteFile("uploads/f2.txt", []byte("file2 content"), 0644)
|
||||
_ = os.WriteFile("uploads/f3.txt", []byte("duplicate name file content"), 0644)
|
||||
_ = os.WriteFile("uploads/f1.txt", []byte("file1 content"), 0o644)
|
||||
_ = os.WriteFile("uploads/f2.txt", []byte("file2 content"), 0o644)
|
||||
_ = os.WriteFile("uploads/f3.txt", []byte("duplicate name file content"), 0o644)
|
||||
|
||||
// Seed upload records. Note f2 and f3 have the same FileName "file_a.txt" to trigger name collision resolution.
|
||||
uploads := []models.Upload{
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"Wavelet/pkg/response"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"Wavelet/pkg/response"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
)
|
||||
|
||||
type trendItem struct {
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
package ingest
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// ErrForbidden indicates the caller is not allowed to mutate the upload record.
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
package ingest
|
||||
|
||||
import (
|
||||
"Wavelet/pkg/idgen"
|
||||
"Wavelet/pkg/logger"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/repository"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
@@ -14,12 +19,8 @@ import (
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"Wavelet/pkg/idgen"
|
||||
"Wavelet/pkg/logger"
|
||||
uploadcache "Wavelet/plugins/domain/upload/cache"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/repository"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
|
||||
uploadstats "Wavelet/plugins/domain/upload/stats"
|
||||
uploadstorage "Wavelet/plugins/domain/upload/storage"
|
||||
)
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
package ingest
|
||||
|
||||
import (
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/repository"
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/repository"
|
||||
)
|
||||
|
||||
// Ingest stores or resolves an upload using the configured policy and side effects.
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
package ingest
|
||||
|
||||
import (
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
@@ -12,10 +15,6 @@ import (
|
||||
"os"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
)
|
||||
|
||||
type testStorageService struct {
|
||||
@@ -64,7 +63,7 @@ func (s *testStorageService) Ingest(_ context.Context, _ io.Reader, _ contracts.
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func setupMockStorage(t *testing.T, putCount *int) (restore func(), disable func()) {
|
||||
func setupMockStorage(t *testing.T, putCount *int) (restore, disable func()) {
|
||||
t.Helper()
|
||||
mockSvc := &testStorageService{
|
||||
mockFiles: make(map[string][]byte),
|
||||
|
||||
@@ -4,14 +4,15 @@
|
||||
package ingest
|
||||
|
||||
import (
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/repository"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
uploadcache "Wavelet/plugins/domain/upload/cache"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/repository"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
|
||||
uploadstats "Wavelet/plugins/domain/upload/stats"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
package ingest
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"io"
|
||||
)
|
||||
|
||||
// Policy controls how ingest handles hash collisions and record creation.
|
||||
|
||||
@@ -5,13 +5,6 @@
|
||||
package upload
|
||||
|
||||
import (
|
||||
"context"
|
||||
"embed"
|
||||
"reflect"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/hibiken/asynq"
|
||||
|
||||
"Wavelet/core"
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/core/extpoints"
|
||||
@@ -19,6 +12,12 @@ import (
|
||||
"Wavelet/plugins/domain/upload/handler"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"Wavelet/plugins/domain/upload/task"
|
||||
"context"
|
||||
"embed"
|
||||
"reflect"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/hibiken/asynq"
|
||||
)
|
||||
|
||||
//go:embed migrations/*/*.sql
|
||||
|
||||
@@ -4,14 +4,13 @@
|
||||
package upload
|
||||
|
||||
import (
|
||||
"Wavelet/pkg/idgen"
|
||||
"Wavelet/pkg/util"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"Wavelet/pkg/idgen"
|
||||
"Wavelet/pkg/util"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
)
|
||||
|
||||
// UploadListFilter filters paginated upload queries.
|
||||
|
||||
@@ -5,14 +5,13 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"Wavelet/pkg/util"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"Wavelet/pkg/util"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
)
|
||||
|
||||
// UploadListFilter filters paginated upload queries.
|
||||
|
||||
@@ -7,8 +7,8 @@ package shared
|
||||
const (
|
||||
MaxUploadSize = 32 * 1024 * 1024 // 32MB
|
||||
DetectContentBytes = 512 // http.DetectContentType 需要的最小字节数
|
||||
UploadDirPerm = 0755 // 上传目录权限
|
||||
UploadFilePerm = 0644 // 上传文件权限
|
||||
UploadDirPerm = 0o755 // 上传目录权限
|
||||
UploadFilePerm = 0o644 // 上传文件权限
|
||||
ImageQualityLow = "low"
|
||||
ImageQualityMedium = "medium"
|
||||
ImageQualityHigh = "high"
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
package shared
|
||||
|
||||
import (
|
||||
"Wavelet/core"
|
||||
"Wavelet/core/contracts"
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"Wavelet/core"
|
||||
"Wavelet/core/contracts"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
package shared
|
||||
|
||||
import (
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/testhelper"
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
@@ -20,9 +22,6 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/testhelper"
|
||||
)
|
||||
|
||||
// MockDBService is a mock implementation of contracts.DBService for unit testing.
|
||||
@@ -130,8 +129,8 @@ func (m *MockStorageService) Put(_ context.Context, key string, body io.Reader,
|
||||
}
|
||||
m.objects[key] = data
|
||||
if strings.HasPrefix(key, "uploads/") {
|
||||
_ = os.MkdirAll(filepath.Dir(key), 0755)
|
||||
_ = os.WriteFile(key, data, 0644)
|
||||
_ = os.MkdirAll(filepath.Dir(key), 0o755)
|
||||
_ = os.WriteFile(key, data, 0o644)
|
||||
}
|
||||
return contracts.StoragePutResult{Key: key, Bucket: "test-bucket"}, nil
|
||||
}
|
||||
@@ -234,7 +233,7 @@ func (a *MockAuthService) VerifyToken(_ context.Context, token string) (*contrac
|
||||
}
|
||||
|
||||
// Authenticate verifies credentials.
|
||||
func (a *MockAuthService) Authenticate(_ context.Context, _ string, _ string) (*contracts.UserDTO, error) {
|
||||
func (a *MockAuthService) Authenticate(_ context.Context, _, _ string) (*contracts.UserDTO, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
package stats
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"Wavelet/plugins/domain/upload/util"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -4,15 +4,14 @@
|
||||
package stats
|
||||
|
||||
import (
|
||||
"Wavelet/pkg/logger"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
|
||||
"Wavelet/pkg/logger"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
)
|
||||
|
||||
// ApplyUploadStatsAdd increments incremental stats for a newly active upload record.
|
||||
|
||||
@@ -4,15 +4,14 @@
|
||||
package stats
|
||||
|
||||
import (
|
||||
"Wavelet/pkg/testhelper"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"Wavelet/pkg/testhelper"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
)
|
||||
|
||||
type mockDBService struct {
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
)
|
||||
|
||||
// MigrationAccessState captures cached migration maintenance state.
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
@@ -11,9 +13,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
)
|
||||
|
||||
// StorageMigrationTask is the task name for storage migration.
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/logger"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// ReadOnly checks if the storage system is in read-only maintenance mode.
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/logger"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -12,11 +16,8 @@ import (
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/logger"
|
||||
uploadcache "Wavelet/plugins/domain/upload/cache"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
|
||||
uploadstats "Wavelet/plugins/domain/upload/stats"
|
||||
uploadstorage "Wavelet/plugins/domain/upload/storage"
|
||||
)
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/logger"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
uploadstats "Wavelet/plugins/domain/upload/stats"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,12 +4,11 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
)
|
||||
|
||||
func TestRebuildUploadStatsHandler_Execute(t *testing.T) {
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/logger"
|
||||
"Wavelet/pkg/util"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
@@ -18,11 +23,6 @@ import (
|
||||
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/logger"
|
||||
"Wavelet/pkg/util"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
uploadstats "Wavelet/plugins/domain/upload/stats"
|
||||
uploadstorage "Wavelet/plugins/domain/upload/storage"
|
||||
)
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
@@ -13,9 +16,6 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
uploadstorage "Wavelet/plugins/domain/upload/storage"
|
||||
)
|
||||
|
||||
@@ -25,11 +25,11 @@ func TestMigrationHandlerExecute(t *testing.T) {
|
||||
|
||||
sourceRoot := t.TempDir()
|
||||
sourcePath := filepath.Join(sourceRoot, "uploads", "test.txt")
|
||||
if err := os.MkdirAll(filepath.Dir(sourcePath), 0755); err != nil {
|
||||
if err := os.MkdirAll(filepath.Dir(sourcePath), 0o755); err != nil {
|
||||
t.Fatalf("MkdirAll(%q) returned error: %v", sourcePath, err)
|
||||
}
|
||||
const content = "storage migration"
|
||||
if err := os.WriteFile(sourcePath, []byte(content), 0644); err != nil {
|
||||
if err := os.WriteFile(sourcePath, []byte(content), 0o644); err != nil {
|
||||
t.Fatalf("WriteFile(%q) returned error: %v", sourcePath, err)
|
||||
}
|
||||
|
||||
@@ -100,11 +100,11 @@ func TestMigrationHandlerExecuteWithHashValidation(t *testing.T) {
|
||||
|
||||
sourceRoot := t.TempDir()
|
||||
sourcePath := filepath.Join(sourceRoot, "uploads", "test-hash.txt")
|
||||
if err := os.MkdirAll(filepath.Dir(sourcePath), 0755); err != nil {
|
||||
if err := os.MkdirAll(filepath.Dir(sourcePath), 0o755); err != nil {
|
||||
t.Fatalf("MkdirAll(%q) returned error: %v", sourcePath, err)
|
||||
}
|
||||
const content = "storage migration integrity check content"
|
||||
if err := os.WriteFile(sourcePath, []byte(content), 0644); err != nil {
|
||||
if err := os.WriteFile(sourcePath, []byte(content), 0o644); err != nil {
|
||||
t.Fatalf("WriteFile(%q) returned error: %v", sourcePath, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,18 +4,17 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/logger"
|
||||
"Wavelet/plugins/domain/upload/filesrv"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/logger"
|
||||
"Wavelet/plugins/domain/upload/filesrv"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"Wavelet/plugins/domain/upload/filesrv"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
@@ -17,10 +20,6 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"Wavelet/plugins/domain/upload/filesrv"
|
||||
"Wavelet/plugins/domain/upload/models"
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
)
|
||||
|
||||
func TestSystemCleanupHandler_Execute(t *testing.T) {
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// IsImageExtension reports whether ext is a common image format.
|
||||
|
||||
@@ -5,20 +5,19 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"image"
|
||||
_ "image/gif" // Register GIF decoder for image.Decode
|
||||
_ "image/jpeg" // Register JPEG decoder for image.Decode
|
||||
_ "image/png" // Register PNG decoder for image.Decode
|
||||
"image" // Register GIF decoder for image.Decode
|
||||
_ "image/gif" // Register JPEG decoder for image.Decode
|
||||
_ "image/jpeg" // Register PNG decoder for image.Decode
|
||||
_ "image/png"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/deepteams/webp"
|
||||
_ "golang.org/x/image/webp" // Register WebP decoder for image.Decode
|
||||
|
||||
"Wavelet/plugins/domain/upload/shared"
|
||||
)
|
||||
|
||||
// ValidateS3Key validates an S3 object key for safety.
|
||||
|
||||
Reference in New Issue
Block a user