Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
edee1820
Commit
edee1820
authored
Jul 21, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
deb3bdd2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
2 deletions
+36
-2
go/zodb/storage/fs1/filestorage.go
go/zodb/storage/fs1/filestorage.go
+36
-2
No files found.
go/zodb/storage/fs1/filestorage.go
View file @
edee1820
...
...
@@ -668,8 +668,8 @@ func (dh *DataHeader) LoadData(r io.ReaderAt /* *os.File */, buf *[]byte) error
return
nil
}
//
Open opens FileStorage XXX text
func
Open
(
ctx
context
.
Context
,
path
string
)
(
*
FileStorage
,
error
)
{
//
open opens FileStorage without loading index
func
open
(
path
string
)
(
*
FileStorage
,
error
)
{
fs
:=
&
FileStorage
{}
f
,
err
:=
os
.
Open
(
path
)
// XXX opens in O_RDONLY
...
...
@@ -688,6 +688,7 @@ func Open(ctx context.Context, path string) (*FileStorage, error) {
return
nil
,
fmt
.
Errorf
(
"%s: invalid magic %q"
,
path
,
xxx
)
// XXX err?
}
/*
// TODO recreate index if missing / not sane (cancel this job on ctx.Done)
// TODO verify index sane / topPos matches
topPos, index, err := LoadIndexFile(path + ".index")
...
...
@@ -695,6 +696,16 @@ func Open(ctx context.Context, path string) (*FileStorage, error) {
panic(err) // XXX err
}
fs.index = index
*/
// determine topPos from file size
// if it is invalid (e.g. a transaction half-way commit) we'll catch it
// while loading/recreating index
fi
,
err
:=
f
.
Stat
()
if
err
!=
nil
{
return
nil
,
err
// XXX err ctx
}
topPos
:=
fi
.
Size
()
// read tidMin/tidMax
// FIXME support empty file case
...
...
@@ -723,6 +734,29 @@ func Open(ctx context.Context, path string) (*FileStorage, error) {
return
fs
,
nil
}
// Open opens FileStorage XXX text
func
Open
(
ctx
context
.
Context
,
path
string
)
(
*
FileStorage
,
error
)
{
fs
,
err
:=
open
(
path
)
if
err
!=
nil
{
return
nil
,
err
}
// TODO recreate index if missing / not sane (cancel this job on ctx.Done)
topPos
,
index
,
err
:=
LoadIndexFile
(
path
+
".index"
)
if
err
!=
nil
{
panic
(
err
)
// XXX err
}
// TODO verify index sane / topPos matches
if
topPos
!=
fs
.
txnhMax
.
Pos
+
fs
.
txnhMax
.
Len
{
panic
(
"inconsistent index topPos"
)
// XXX
}
fs
.
index
=
index
return
fs
,
nil
}
func
(
fs
*
FileStorage
)
LastTid
()
(
zodb
.
Tid
,
error
)
{
// XXX check we have transactions at all
...
...
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