Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
b664d749
Commit
b664d749
authored
Nov 05, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/zodb/fs1: Factor-out noEOF and okEOF into common place (-> internal/xio)
We will need to use those utilities for ZEO and NEO.
parent
58689cb6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
20 deletions
+25
-20
go/internal/xio/xio.go
go/internal/xio/xio.go
+19
-2
go/zodb/storage/fs1/util.go
go/zodb/storage/fs1/util.go
+6
-18
No files found.
go/internal/xio/xio.go
View file @
b664d749
// Copyright (C) 2017 Nexedi SA and Contributors.
// Copyright (C) 2017
-2020
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
Kirill Smelkov <kirr@nexedi.com>
//
//
// This program is free software: you can Use, Study, Modify and Redistribute
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// it under the terms of the GNU General Public License version 3, or (at your
...
@@ -28,6 +28,23 @@ import (
...
@@ -28,6 +28,23 @@ import (
"lab.nexedi.com/kirr/neo/go/internal/xcontext"
"lab.nexedi.com/kirr/neo/go/internal/xcontext"
)
)
// NoEOF returns err, but changes io.EOF -> io.ErrUnexpectedEOF.
func
NoEOF
(
err
error
)
error
{
if
err
==
io
.
EOF
{
err
=
io
.
ErrUnexpectedEOF
}
return
err
}
// EOFok returns err, but changes io.EOF -> nil.
func
EOFok
(
err
error
)
error
{
if
err
==
io
.
EOF
{
err
=
nil
}
return
err
}
// CloseWhenDone arranges for c to be closed either when ctx is cancelled or
// CloseWhenDone arranges for c to be closed either when ctx is cancelled or
// surrounding function returns.
// surrounding function returns.
//
//
...
...
go/zodb/storage/fs1/util.go
View file @
b664d749
// Copyright (C) 2017 Nexedi SA and Contributors.
// Copyright (C) 2017
-2020
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
Kirill Smelkov <kirr@nexedi.com>
//
//
// This program is free software: you can Use, Study, Modify and Redistribute
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// it under the terms of the GNU General Public License version 3, or (at your
...
@@ -20,27 +20,15 @@
...
@@ -20,27 +20,15 @@
package
fs1
package
fs1
import
(
import
(
"io"
"os"
"os"
"lab.nexedi.com/kirr/neo/go/internal/xio"
"lab.nexedi.com/kirr/go123/xbufio"
"lab.nexedi.com/kirr/go123/xbufio"
)
)
// noEOF returns err, but changes io.EOF -> io.ErrUnexpectedEOF
// noEOF and okEOF are syntactic sugar over xio.NoEOF and xio.EOFok.
func
noEOF
(
err
error
)
error
{
func
noEOF
(
err
error
)
error
{
return
xio
.
NoEOF
(
err
)
}
if
err
==
io
.
EOF
{
func
okEOF
(
err
error
)
error
{
return
xio
.
EOFok
(
err
)
}
err
=
io
.
ErrUnexpectedEOF
}
return
err
}
// okEOF returns err, but changes io.EOF -> nil
func
okEOF
(
err
error
)
error
{
if
err
==
io
.
EOF
{
err
=
nil
}
return
err
}
// record reading routines work on abstract file-like interfaces.
// record reading routines work on abstract file-like interfaces.
// when they report e.g. decoding error, if reader has name, e.g. as os.File
// when they report e.g. decoding error, if reader has name, e.g. as os.File
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment