Skip to content

Commit

Permalink
feat: Removing id conversion
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Nov 14, 2022
1 parent eb288e1 commit 2f64023
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 31 deletions.
3 changes: 0 additions & 3 deletions pkg/exif/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ func (a App) EventConsumer(ctx context.Context, e provider.Event) {

switch e.Type {
case provider.StartEvent:
if err := provider.RenamePreviousID(ctx, a.storageApp, e.Item, ".json", a.Rename); err != nil {
logger.Error("rename from previous ID: %s", err)
}
if err = a.handleStartEvent(ctx, e); err != nil {
getEventLogger(e.Item).Error("start: %s", err)
}
Expand Down
25 changes: 0 additions & 25 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package provider

import (
"context"
"crypto/sha256"
"encoding/hex"
"path"
"path/filepath"

absto "github.com/ViBiOh/absto/pkg/model"
Expand Down Expand Up @@ -41,24 +37,3 @@ func MetadataDirectory(item absto.Item) string {

return Dirname(MetadataDirectoryName + pathname)
}

func itemPreviousID(item absto.Item) string {
hasher := sha256.New()
_, _ = hasher.Write([]byte(item.Pathname))
return hex.EncodeToString(hasher.Sum(nil))
}

func RenamePreviousID(ctx context.Context, storageApp absto.Storage, item absto.Item, suffix string, renameFunc func(context.Context, absto.Item, absto.Item) error) error {
if _, err := storageApp.Info(ctx, path.Join(MetadataDirectory(item), itemPreviousID(item)+suffix)); err != nil {
if absto.IsNotExist(err) {
return nil
}

return err
}

previous := item
previous.ID = itemPreviousID(previous)

return renameFunc(ctx, previous, item)
}
3 changes: 0 additions & 3 deletions pkg/thumbnail/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ func (a App) EventConsumer(ctx context.Context, e provider.Event) {

switch e.Type {
case provider.StartEvent:
if err := provider.RenamePreviousID(ctx, a.storageApp, e.Item, ".webp", a.Rename); err != nil {
logger.Error("rename from previous ID: %s", err)
}
fallthrough
case provider.UploadEvent:
a.generateItem(ctx, e)
Expand Down

0 comments on commit 2f64023

Please sign in to comment.