Исправление "двоения" ErrNotFound x2
This commit is contained in:
25
manager.go
25
manager.go
@@ -13,6 +13,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gitea.unprism.ru/KRBL/Agate/models"
|
||||
"github.com/google/uuid"
|
||||
|
||||
"gitea.unprism.ru/KRBL/Agate/archive"
|
||||
@@ -49,13 +50,13 @@ func (data *SnapshotManagerData) CreateSnapshot(ctx context.Context, sourceDir s
|
||||
info, err := os.Stat(sourceDir)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return nil, ErrSourceNotFound
|
||||
return nil, models.ErrSourceNotFound
|
||||
}
|
||||
return nil, fmt.Errorf("failed to access source directory: %w", err)
|
||||
}
|
||||
|
||||
if !info.IsDir() {
|
||||
return nil, ErrSourceNotDirectory
|
||||
return nil, models.ErrSourceNotDirectory
|
||||
}
|
||||
|
||||
// Check if parent exists if specified
|
||||
@@ -165,8 +166,8 @@ func (data *SnapshotManagerData) GetSnapshotDetails(ctx context.Context, snapsho
|
||||
// Retrieve snapshot metadata from the store
|
||||
snapshot, err := data.metadataStore.GetSnapshotMetadata(ctx, snapshotID)
|
||||
if err != nil {
|
||||
if errors.Is(err, ErrNotFound) {
|
||||
return nil, ErrNotFound
|
||||
if errors.Is(err, models.ErrNotFound) {
|
||||
return nil, models.ErrNotFound
|
||||
}
|
||||
return nil, fmt.Errorf("failed to retrieve snapshot details: %w", err)
|
||||
}
|
||||
@@ -191,7 +192,7 @@ func (data *SnapshotManagerData) DeleteSnapshot(ctx context.Context, snapshotID
|
||||
|
||||
snapshot, err := data.metadataStore.GetSnapshotMetadata(ctx, snapshotID)
|
||||
if err != nil {
|
||||
if errors.Is(err, ErrNotFound) {
|
||||
if errors.Is(err, models.ErrNotFound) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("failed to check if snapshot exists: %w", err)
|
||||
@@ -237,8 +238,8 @@ func (data *SnapshotManagerData) OpenFile(ctx context.Context, snapshotID string
|
||||
// First check if the snapshot exists
|
||||
_, err := data.metadataStore.GetSnapshotMetadata(ctx, snapshotID)
|
||||
if err != nil {
|
||||
if errors.Is(err, ErrNotFound) {
|
||||
return nil, ErrNotFound
|
||||
if errors.Is(err, models.ErrNotFound) {
|
||||
return nil, models.ErrNotFound
|
||||
}
|
||||
return nil, fmt.Errorf("failed to check if snapshot exists: %w", err)
|
||||
}
|
||||
@@ -261,7 +262,7 @@ func (data *SnapshotManagerData) OpenFile(ctx context.Context, snapshotID string
|
||||
err := archive.ExtractFileFromArchive(blobPath, filePath, pw)
|
||||
if err != nil {
|
||||
if errors.Is(err, archive.ErrFileNotFoundInArchive) {
|
||||
pw.CloseWithError(ErrFileNotFound)
|
||||
pw.CloseWithError(models.ErrFileNotFound)
|
||||
return
|
||||
}
|
||||
pw.CloseWithError(fmt.Errorf("failed to extract file from archive: %w", err))
|
||||
@@ -284,8 +285,8 @@ func (data *SnapshotManagerData) ExtractSnapshot(ctx context.Context, snapshotID
|
||||
// First check if the snapshot exists
|
||||
_, err := data.metadataStore.GetSnapshotMetadata(ctx, snapshotID)
|
||||
if err != nil {
|
||||
if errors.Is(err, ErrNotFound) {
|
||||
return ErrNotFound
|
||||
if errors.Is(err, models.ErrNotFound) {
|
||||
return models.ErrNotFound
|
||||
}
|
||||
return fmt.Errorf("failed to check if snapshot exists: %w", err)
|
||||
}
|
||||
@@ -388,8 +389,8 @@ func (data *SnapshotManagerData) UpdateSnapshotMetadata(ctx context.Context, sna
|
||||
|
||||
snapshot, err := data.metadataStore.GetSnapshotMetadata(ctx, snapshotID)
|
||||
if err != nil {
|
||||
if errors.Is(err, ErrNotFound) {
|
||||
return ErrNotFound
|
||||
if errors.Is(err, models.ErrNotFound) {
|
||||
return models.ErrNotFound
|
||||
}
|
||||
return fmt.Errorf("failed to get snapshot metadata: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user