Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-ds-flatfs
Commits
925e2544
Unverified
Commit
925e2544
authored
Feb 12, 2017
by
Jakub Sztandera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unfinished write transactions
parent
5274262c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
2 deletions
+34
-2
convert.go
convert.go
+34
-2
No files found.
convert.go
View file @
925e2544
...
@@ -4,10 +4,12 @@
...
@@ -4,10 +4,12 @@
package
flatfs
package
flatfs
import
(
import
(
"errors"
"fmt"
"fmt"
"io"
"io"
"os"
"os"
"path/filepath"
"path/filepath"
"strings"
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/query"
"github.com/ipfs/go-datastore/query"
...
@@ -110,8 +112,38 @@ func Move(oldPath string, newPath string, out io.Writer) error {
...
@@ -110,8 +112,38 @@ func Move(oldPath string, newPath string, out io.Writer) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
inf
.
IsDir
()
||
fn
==
SHARDING_FN
||
fn
==
README_FN
{
if
inf
.
IsDir
()
{
// we are an empty directory or generated file so just remove it
indir
,
err
:=
os
.
Open
(
oldPath
)
if
err
!=
nil
{
return
err
}
defer
indir
.
Close
()
names
,
err
:=
indir
.
Readdirnames
(
-
1
)
if
err
!=
nil
{
return
err
}
for
_
,
n
:=
range
names
{
p
:=
filepath
.
Join
(
oldPath
,
n
)
// part of unfinished write transaction
// remove it
if
strings
.
HasPrefix
(
n
,
"put-"
)
{
err
:=
os
.
Remove
(
p
)
if
err
!=
nil
{
return
err
}
}
else
{
return
errors
.
New
(
"unknown file in flatfs: "
+
p
)
}
}
err
=
os
.
Remove
(
oldPath
)
if
err
!=
nil
{
return
err
}
}
else
if
fn
==
SHARDING_FN
||
fn
==
README_FN
{
// generated file so just remove it
err
:=
os
.
Remove
(
oldPath
)
err
:=
os
.
Remove
(
oldPath
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
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