From 644a94656af13eb636ebc1510c16b2c4d4638c02 Mon Sep 17 00:00:00 2001 From: Alexander Lazarenko Date: Thu, 30 Oct 2025 01:50:32 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20"=D0=B4=D0=B2=D0=BE=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F"=20`ErrNotFound`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manager.go | 4 ++-- store/errors.go | 9 --------- store/filesystem/filesystem.go | 5 +++-- store/sqlite/sqlite.go | 3 ++- 4 files changed, 7 insertions(+), 14 deletions(-) delete mode 100644 store/errors.go diff --git a/manager.go b/manager.go index 262bcd6..5099f19 100644 --- a/manager.go +++ b/manager.go @@ -191,7 +191,7 @@ func (data *SnapshotManagerData) DeleteSnapshot(ctx context.Context, snapshotID snapshot, err := data.metadataStore.GetSnapshotMetadata(ctx, snapshotID) if err != nil { - if errors.Is(err, store.ErrNotFound) { + if errors.Is(err, ErrNotFound) { return nil } return fmt.Errorf("failed to check if snapshot exists: %w", err) @@ -388,7 +388,7 @@ func (data *SnapshotManagerData) UpdateSnapshotMetadata(ctx context.Context, sna snapshot, err := data.metadataStore.GetSnapshotMetadata(ctx, snapshotID) if err != nil { - if errors.Is(err, store.ErrNotFound) { + if errors.Is(err, ErrNotFound) { return ErrNotFound } return fmt.Errorf("failed to get snapshot metadata: %w", err) diff --git a/store/errors.go b/store/errors.go deleted file mode 100644 index bfe3469..0000000 --- a/store/errors.go +++ /dev/null @@ -1,9 +0,0 @@ -package store - -import "errors" - -// Common errors that can be used by store implementations -var ( - // ErrNotFound means that a requested resource was not found - ErrNotFound = errors.New("resource not found") -) diff --git a/store/filesystem/filesystem.go b/store/filesystem/filesystem.go index 1d6c632..57ca0da 100644 --- a/store/filesystem/filesystem.go +++ b/store/filesystem/filesystem.go @@ -7,6 +7,7 @@ import ( "os" "path/filepath" + agate "gitea.unprism.ru/KRBL/Agate" "gitea.unprism.ru/KRBL/Agate/store" ) @@ -75,7 +76,7 @@ func (fs *fileSystemStore) RetrieveBlob(ctx context.Context, snapshotID string) if err != nil { if os.IsNotExist(err) { // Если файл не найден, возвращаем кастомную ошибку - return nil, store.ErrNotFound + return nil, agate.ErrNotFound } return nil, fmt.Errorf("failed to open blob file %s: %w", blobPath, err) } @@ -109,7 +110,7 @@ func (fs *fileSystemStore) GetBlobPath(ctx context.Context, snapshotID string) ( // Проверяем существование файла if _, err := os.Stat(blobPath); err != nil { if os.IsNotExist(err) { - return "", store.ErrNotFound + return "", agate.ErrNotFound } return "", fmt.Errorf("failed to stat blob file %s: %w", blobPath, err) } diff --git a/store/sqlite/sqlite.go b/store/sqlite/sqlite.go index e3f7167..8e8782f 100644 --- a/store/sqlite/sqlite.go +++ b/store/sqlite/sqlite.go @@ -6,6 +6,7 @@ import ( "encoding/json" "errors" "fmt" + agate "gitea.unprism.ru/KRBL/Agate" "gitea.unprism.ru/KRBL/Agate/store" _ "github.com/mattn/go-sqlite3" "os" @@ -130,7 +131,7 @@ func (s *sqliteStore) GetSnapshotMetadata(ctx context.Context, snapshotID string if err != nil { if errors.Is(err, sql.ErrNoRows) { // Если запись не найдена, возвращаем кастомную ошибку - return nil, store.ErrNotFound + return nil, agate.ErrNotFound } return nil, fmt.Errorf("failed to query snapshot %s: %w", snapshotID, err) }