Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions adapters/googlePhotos/googlephotos.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package gp
import (
"bytes"
"context"
"errors"
"io/fs"
"log/slog"
"path"
Expand Down Expand Up @@ -95,6 +96,11 @@ func (toc *TakeoutCmd) Browse(ctx context.Context) chan *assets.Group {
func (toc *TakeoutCmd) passOneFsWalk(ctx context.Context, w fs.FS) error {
err := fs.WalkDir(w, ".", func(name string, d fs.DirEntry, err error) error {
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
// This branch can happen when you have symbolic links.
return nil
}

return err
}

Expand Down
32 changes: 32 additions & 0 deletions adapters/googlePhotos/googlephotos_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package gp

import (
"io/fs"
"testing"
)

// mockFS implements a simple fs.FS for testing
type mockFS struct{}

func (m mockFS) Open(name string) (fs.File, error) {
return nil, fs.ErrNotExist
}

func (m mockFS) Name() string {
return "test.zip"
}

func Test_TakeoutCmd_passOneFsWalk(t *testing.T) {
t.Parallel()

t.Run("pass: fs.ErrNotExist should not error", func(t *testing.T) {
t.Parallel()

toc := &TakeoutCmd{}

err := toc.passOneFsWalk(t.Context(), mockFS{})
if err != nil {
t.Fatalf("expected no error, got %v", err)
}
})
}