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) }