Skip to content

Commit 31a5c6a

Browse files
committed
ipfs: use standard fs error values
1 parent f18803c commit 31a5c6a

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

internal/filesystem/ipfs/ipfs.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ func (fsys *IPFS) Open(name string) (fs.File, error) {
319319
}
320320
const op = "open"
321321
if !fs.ValidPath(name) {
322-
return nil, fserrors.New(op, name, filesystem.ErrPath, fserrors.InvalidItem)
322+
return nil, fserrors.New(op, name, fs.ErrInvalid, fserrors.InvalidItem)
323323
}
324324
cid, err := fsys.toCID(op, name)
325325
if err != nil {
@@ -482,7 +482,7 @@ func (id *ipfsDirectory) StreamDir() <-chan filesystem.StreamDirEntry {
482482
// TODO: We don't have an error kind
483483
// that translates into EBADF
484484
errs <- newErrorEntry(
485-
fserrors.New(op, id.info.name, filesystem.ErrNotOpen, fserrors.IO),
485+
fserrors.New(op, id.info.name, fs.ErrClosed, fserrors.IO),
486486
)
487487
return errs
488488
}
@@ -498,7 +498,7 @@ func (id *ipfsDirectory) ReadDir(count int) ([]fs.DirEntry, error) {
498498
if stream == nil {
499499
// TODO: We don't have an error kind
500500
// that translates into EBADF
501-
return nil, fserrors.New(op, id.info.name, filesystem.ErrNotOpen, fserrors.IO)
501+
return nil, fserrors.New(op, id.info.name, fs.ErrClosed, fserrors.IO)
502502
}
503503
var (
504504
ctx = stream.Context
@@ -519,5 +519,5 @@ func (id *ipfsDirectory) Close() error {
519519
id.stream = nil
520520
return nil
521521
}
522-
return fserrors.New(op, id.info.name, filesystem.ErrNotOpen, fserrors.InvalidItem)
522+
return fserrors.New(op, id.info.name, fs.ErrClosed, fserrors.InvalidItem)
523523
}

internal/filesystem/ipfs/ipns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ func (fsys *IPNS) Open(name string) (fs.File, error) {
257257
}
258258
const op = "open"
259259
if !fs.ValidPath(name) {
260-
return nil, fserrors.New(op, name, filesystem.ErrPath, fserrors.InvalidItem)
260+
return nil, fserrors.New(op, name, fs.ErrInvalid, fserrors.InvalidItem)
261261
}
262262
cid, err := fsys.toCID(op, name)
263263
if err != nil {

internal/filesystem/ipfs/keyfs.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (kfs *KeyFS) Stat(name string) (fs.FileInfo, error) {
112112
if subsys := kfs.ipns; subsys != nil {
113113
return fs.Stat(subsys, name)
114114
}
115-
return nil, fserrors.New(op, name, filesystem.ErrNotFound, fserrors.NotExist)
115+
return nil, fserrors.New(op, name, fs.ErrNotExist, fserrors.NotExist)
116116
}
117117

118118
func (kfs *KeyFS) Open(name string) (fs.File, error) {
@@ -131,7 +131,7 @@ func (kfs *KeyFS) Open(name string) (fs.File, error) {
131131
if subsys := kfs.ipns; subsys != nil {
132132
return subsys.Open(translated)
133133
}
134-
return nil, fserrors.New(op, name, filesystem.ErrNotFound, fserrors.NotExist)
134+
return nil, fserrors.New(op, name, fs.ErrNotExist, fserrors.NotExist)
135135
}
136136

137137
func (kfs *KeyFS) openRoot() (fs.ReadDirFile, error) {
@@ -192,7 +192,7 @@ func (kd *keyDirectory) ReadDir(count int) ([]fs.DirEntry, error) {
192192
}
193193
stream := kd.stream
194194
if stream == nil {
195-
return nil, fserrors.New(op, filesystem.Root, filesystem.ErrNotOpen, fserrors.IO)
195+
return nil, fserrors.New(op, filesystem.Root, fs.ErrClosed, fserrors.IO)
196196
}
197197
var (
198198
ctx = stream.Context
@@ -216,7 +216,7 @@ func (kd *keyDirectory) Close() error {
216216
kd.stream = nil
217217
return nil
218218
}
219-
return fserrors.New(op, filesystem.Root, filesystem.ErrNotOpen, fserrors.InvalidItem)
219+
return fserrors.New(op, filesystem.Root, fs.ErrClosed, fserrors.InvalidItem)
220220
}
221221

222222
func pathWithoutNamespace(key coreiface.Key) string {

internal/filesystem/ipfs/pinfs.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (pfs *PinFS) Stat(name string) (fs.FileInfo, error) {
129129
if subsys := pfs.ipfs; subsys != nil {
130130
return fs.Stat(subsys, name)
131131
}
132-
return nil, fserrors.New(op, name, filesystem.ErrNotFound, fserrors.NotExist)
132+
return nil, fserrors.New(op, name, fs.ErrNotExist, fserrors.NotExist)
133133
}
134134

135135
func (pfs *PinFS) Open(name string) (fs.File, error) {
@@ -140,7 +140,7 @@ func (pfs *PinFS) Open(name string) (fs.File, error) {
140140
if subsys := pfs.ipfs; subsys != nil {
141141
return subsys.Open(name)
142142
}
143-
return nil, fserrors.New(op, name, filesystem.ErrNotFound, fserrors.NotExist)
143+
return nil, fserrors.New(op, name, fs.ErrNotExist, fserrors.NotExist)
144144
}
145145

146146
func (pfs *PinFS) openRoot() (fs.ReadDirFile, error) {
@@ -285,7 +285,7 @@ func (pd *pinDirectory) ReadDir(count int) ([]fs.DirEntry, error) {
285285
if stream == nil {
286286
// TODO: We don't have an error kind
287287
// that translates into EBADF
288-
return nil, fserrors.New(op, filesystem.Root, filesystem.ErrNotOpen, fserrors.IO)
288+
return nil, fserrors.New(op, filesystem.Root, fs.ErrClosed, fserrors.IO)
289289
}
290290
var (
291291
ctx = stream.Context
@@ -307,7 +307,7 @@ func (pd *pinDirectory) StreamDir() <-chan filesystem.StreamDirEntry {
307307
// TODO: We don't have an error kind
308308
// that translates into EBADF
309309
errs <- newErrorEntry(
310-
fserrors.New(op, filesystem.Root, filesystem.ErrNotOpen, fserrors.IO),
310+
fserrors.New(op, filesystem.Root, fs.ErrClosed, fserrors.IO),
311311
)
312312
return errs
313313
}
@@ -323,7 +323,7 @@ func (pd *pinDirectory) Close() error {
323323
}
324324
// TODO: We don't have an error kind
325325
// that translates into EBADF
326-
return fserrors.New(op, filesystem.Root, filesystem.ErrNotOpen, fserrors.IO)
326+
return fserrors.New(op, filesystem.Root, fs.ErrClosed, fserrors.IO)
327327
}
328328

329329
func (pe *pinDirEntry) Name() string {

0 commit comments

Comments
 (0)