filer: option to create file only if it is new, O_EXCL
This commit is contained in:
@@ -139,7 +139,7 @@ func (fs *FilerServer) CreateEntry(ctx context.Context, req *filer_pb.CreateEntr
|
||||
FullPath: fullpath,
|
||||
Attr: filer2.PbToEntryAttribute(req.Entry.Attributes),
|
||||
Chunks: chunks,
|
||||
})
|
||||
}, req.OExcl)
|
||||
|
||||
if err == nil {
|
||||
fs.filer.DeleteChunks(garbages)
|
||||
|
||||
@@ -107,7 +107,7 @@ func (fs *FilerServer) moveSelfEntry(ctx context.Context, oldParent filer2.FullP
|
||||
Attr: entry.Attr,
|
||||
Chunks: entry.Chunks,
|
||||
}
|
||||
createErr := fs.filer.CreateEntry(ctx, newEntry)
|
||||
createErr := fs.filer.CreateEntry(ctx, newEntry, false)
|
||||
if createErr != nil {
|
||||
return createErr
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ func (fs *FilerServer) updateFilerStore(ctx context.Context, r *http.Request, w
|
||||
entry.Attr.Mime = mime.TypeByExtension(ext)
|
||||
}
|
||||
// glog.V(4).Infof("saving %s => %+v", path, entry)
|
||||
if dbErr := fs.filer.CreateEntry(ctx, entry); dbErr != nil {
|
||||
if dbErr := fs.filer.CreateEntry(ctx, entry, false); dbErr != nil {
|
||||
fs.filer.DeleteChunks(entry.Chunks)
|
||||
glog.V(0).Infof("failing to write %s to filer server : %v", path, dbErr)
|
||||
writeJsonError(w, r, http.StatusInternalServerError, dbErr)
|
||||
|
||||
@@ -176,7 +176,7 @@ func (fs *FilerServer) doAutoChunk(ctx context.Context, w http.ResponseWriter, r
|
||||
},
|
||||
Chunks: fileChunks,
|
||||
}
|
||||
if dbErr := fs.filer.CreateEntry(ctx, entry); dbErr != nil {
|
||||
if dbErr := fs.filer.CreateEntry(ctx, entry, false); dbErr != nil {
|
||||
fs.filer.DeleteChunks(entry.Chunks)
|
||||
replyerr = dbErr
|
||||
filerResult.Error = dbErr.Error()
|
||||
|
||||
Reference in New Issue
Block a user