Skip to content

Commit 4cc0847

Browse files
committed
remove check if local repository exists when using a loopback
1 parent ca9ed03 commit 4cc0847

1 file changed

Lines changed: 12 additions & 31 deletions

File tree

fstree/repository.go

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ package fstree
22

33
import (
44
"context"
5-
"errors"
65
"fmt"
7-
"os"
86
"syscall"
9-
"time"
107

118
"github.com/badjware/gitforgefs/types"
129
"github.com/hanwen/go-fuse/v2/fs"
@@ -51,34 +48,18 @@ func newRepositoryNodeFromSource(ctx context.Context, source types.RepositorySou
5148
if err != nil {
5249
return nil, fmt.Errorf("failed to fetch local repository path: %w", err)
5350
}
54-
// The path must exist to successfully create a loopback. We poll the filesystem until its created.
55-
// This of course add latency, maybe we should think of a way of mitigating it in the future.
56-
// We do not care in the case of a symlink. A symlink pointing on nothing is still a valid symlink.
57-
for ctx.Err() == nil {
58-
var st syscall.Stat_t
59-
err := syscall.Stat(localRepositoryPath, &st)
60-
if err == nil {
61-
// rootData := &fs.LoopbackRoot{
62-
// Path: localRepositoryPath,
63-
// Dev: st.Dev,
64-
// }
65-
// rootNode := &fs.LoopbackNode{
66-
// RootData: rootData,
67-
// }
68-
// rootData.RootNode = rootNode
69-
// return rootNode, nil
70-
return fs.NewLoopbackRoot(localRepositoryPath)
71-
} else if errors.Is(err, os.ErrNotExist) {
72-
// wait for the file to be created
73-
// TODO: think of a more efficient way of archiving this
74-
time.Sleep(100 * time.Millisecond)
75-
} else {
76-
// error, filesystem
77-
return nil, fmt.Errorf("error while waiting for the local repository to be created: %w", err)
78-
}
79-
}
80-
// error, context cancelled
81-
return nil, fmt.Errorf("context cancelled while waiting for the local repository to be created: %w", ctx.Err())
51+
// var st syscall.Stat_t
52+
// err := syscall.Stat(localRepositoryPath, &st)
53+
// rootData := &fs.LoopbackRoot{
54+
// Path: localRepositoryPath,
55+
// Dev: st.Dev,
56+
// }
57+
// rootNode := &fs.LoopbackNode{
58+
// RootData: rootData,
59+
// }
60+
// rootData.RootNode = rootNode
61+
// return rootNode, nil
62+
return fs.NewLoopbackRoot(localRepositoryPath)
8263
}
8364
}
8465

0 commit comments

Comments
 (0)