Skip to content

Commit

Permalink
fix(embedded/appendable): fsync parent folder in remote appedable
Browse files Browse the repository at this point in the history
Signed-off-by: Jeronimo Irazabal <[email protected]>
  • Loading branch information
jeroiraz committed Nov 7, 2022
1 parent d72a54a commit 09f4613
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions embedded/appendable/remoteapp/remote_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"time"

"github.com/codenotary/immudb/embedded/appendable"
"github.com/codenotary/immudb/embedded/appendable/fileutils"
"github.com/codenotary/immudb/embedded/appendable/multiapp"
"github.com/codenotary/immudb/embedded/appendable/singleapp"
"github.com/codenotary/immudb/embedded/cache"
Expand Down Expand Up @@ -264,7 +265,12 @@ func (r *RemoteStorageAppendable) uploadChunk(chunkID int64, dontRemoveFile bool
r.chunkInfos[chunkID].cancelUpload = nil
r.mutex.Unlock()

return os.Remove(path.Join(r.path, appName))
err := os.Remove(path.Join(r.path, appName))
if err != nil {
return nil
}

return fileutils.SyncDir(r.path)
})

if ctx.Err() != nil {
Expand Down Expand Up @@ -354,7 +360,12 @@ func (r *RemoteStorageAppendable) downloadChunk(chunkID int64) {
return flTmp.Close()
})
cp.Step(func() error {
return os.Rename(fileNameTmp, fileName)
err := os.Rename(fileNameTmp, fileName)
if err != nil {
return err
}

return fileutils.SyncDir(r.path)
})

if ctx.Err() != nil {
Expand Down

0 comments on commit 09f4613

Please sign in to comment.