Исправление "двоения" ErrNotFound
This commit is contained in:
@@ -191,7 +191,7 @@ func (data *SnapshotManagerData) DeleteSnapshot(ctx context.Context, snapshotID
|
|||||||
|
|
||||||
snapshot, err := data.metadataStore.GetSnapshotMetadata(ctx, snapshotID)
|
snapshot, err := data.metadataStore.GetSnapshotMetadata(ctx, snapshotID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, store.ErrNotFound) {
|
if errors.Is(err, ErrNotFound) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("failed to check if snapshot exists: %w", err)
|
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)
|
snapshot, err := data.metadataStore.GetSnapshotMetadata(ctx, snapshotID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, store.ErrNotFound) {
|
if errors.Is(err, ErrNotFound) {
|
||||||
return ErrNotFound
|
return ErrNotFound
|
||||||
}
|
}
|
||||||
return fmt.Errorf("failed to get snapshot metadata: %w", err)
|
return fmt.Errorf("failed to get snapshot metadata: %w", err)
|
||||||
|
|||||||
@@ -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")
|
|
||||||
)
|
|
||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
agate "gitea.unprism.ru/KRBL/Agate"
|
||||||
"gitea.unprism.ru/KRBL/Agate/store"
|
"gitea.unprism.ru/KRBL/Agate/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -75,7 +76,7 @@ func (fs *fileSystemStore) RetrieveBlob(ctx context.Context, snapshotID string)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
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)
|
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 _, err := os.Stat(blobPath); err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return "", store.ErrNotFound
|
return "", agate.ErrNotFound
|
||||||
}
|
}
|
||||||
return "", fmt.Errorf("failed to stat blob file %s: %w", blobPath, err)
|
return "", fmt.Errorf("failed to stat blob file %s: %w", blobPath, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
agate "gitea.unprism.ru/KRBL/Agate"
|
||||||
"gitea.unprism.ru/KRBL/Agate/store"
|
"gitea.unprism.ru/KRBL/Agate/store"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
"os"
|
"os"
|
||||||
@@ -130,7 +131,7 @@ func (s *sqliteStore) GetSnapshotMetadata(ctx context.Context, snapshotID string
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
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)
|
return nil, fmt.Errorf("failed to query snapshot %s: %w", snapshotID, err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user