mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-09-25 13:37:09 -04:00
chore: bump reva to 295fe6437
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
1 parent
040c3bf08e
commit
adfc2ba5bb
11 files changed
+243
-118
No files matched your search
@@ -64,7 +64,7 @@ require (
|
||||
github.com/open-policy-agent/opa v1.19.1
|
||||
github.com/opencloud-eu/icap-client v0.0.0-20250930132611-28a2afe62d89
|
||||
github.com/opencloud-eu/libre-graph-api-go v1.0.8-0.20260902170011-45af3945a067
|
||||
github.com/opencloud-eu/reva/v2 v2.50.1-0.20260924091259-7fa82c610dba
|
||||
github.com/opencloud-eu/reva/v2 v2.50.1-0.20260924114030-295fe643704f
|
||||
github.com/opensearch-project/opensearch-go/v4 v4.7.3
|
||||
github.com/orcaman/concurrent-map v1.0.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
|
||||
@@ -930,8 +930,8 @@ github.com/opencloud-eu/icap-client v0.0.0-20250930132611-28a2afe62d89 h1:W1ms+l
|
||||
github.com/opencloud-eu/icap-client v0.0.0-20250930132611-28a2afe62d89/go.mod h1:vigJkNss1N2QEceCuNw/ullDehncuJNFB6mEnzfq9UI=
|
||||
github.com/opencloud-eu/libre-graph-api-go v1.0.8-0.20260902170011-45af3945a067 h1:UkNMKauyJAzY6RE6mmthz9bQZLYkbvBuApm7ZDCparE=
|
||||
github.com/opencloud-eu/libre-graph-api-go v1.0.8-0.20260902170011-45af3945a067/go.mod h1:lTM8JeGblNpoMySTW7Lui2+c5TTLI95mwxtdUIHHrhU=
|
||||
github.com/opencloud-eu/reva/v2 v2.50.1-0.20260924091259-7fa82c610dba h1:EmOM04qHWNsoT3F49bVfb3jQglHHSIbBvkol3eMV8Uo=
|
||||
github.com/opencloud-eu/reva/v2 v2.50.1-0.20260924091259-7fa82c610dba/go.mod h1:UnhCBGqcuhLkOhrmvbEsiBaDiD5uDGzaylnoc+QzJNs=
|
||||
github.com/opencloud-eu/reva/v2 v2.50.1-0.20260924114030-295fe643704f h1:60BWWuYRUkLhcdyto+5/sKnWx85F0VtS/VWxK9w4V+0=
|
||||
github.com/opencloud-eu/reva/v2 v2.50.1-0.20260924114030-295fe643704f/go.mod h1:UnhCBGqcuhLkOhrmvbEsiBaDiD5uDGzaylnoc+QzJNs=
|
||||
github.com/opencloud-eu/secure v0.0.0-20260312082735-b6f5cb2244e4 h1:l2oB/RctH+t8r7QBj5p8thfEHCM/jF35aAY3WQ3hADI=
|
||||
github.com/opencloud-eu/secure v0.0.0-20260312082735-b6f5cb2244e4/go.mod h1:BmF5hyM6tXczk3MpQkFf1hpKSRqCyhqcbiQtiAF7+40=
|
||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||
|
||||
Generated
Vendored
+12
-1
@@ -27,6 +27,7 @@ import (
|
||||
ctxpkg "github.com/opencloud-eu/reva/v2/pkg/ctx"
|
||||
sdk "github.com/opencloud-eu/reva/v2/pkg/sdk/common"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storage/cache"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/storagespace"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/utils"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/grpc"
|
||||
@@ -129,7 +130,17 @@ func (c *cachedSpacesAPIClient) UpdateStorageSpace(ctx context.Context, in *prov
|
||||
return c.c.UpdateStorageSpace(ctx, in, opts...)
|
||||
}
|
||||
func (c *cachedSpacesAPIClient) DeleteStorageSpace(ctx context.Context, in *provider.DeleteStorageSpaceRequest, opts ...grpc.CallOption) (*provider.DeleteStorageSpaceResponse, error) {
|
||||
return c.c.DeleteStorageSpace(ctx, in, opts...)
|
||||
resp, err := c.c.DeleteStorageSpace(ctx, in, opts...)
|
||||
switch {
|
||||
case err != nil:
|
||||
return nil, err
|
||||
case resp.Status.Code != rpc.Code_CODE_OK:
|
||||
return resp, nil
|
||||
default:
|
||||
_, spaceid, _, _ := storagespace.SplitID(in.GetId().GetOpaqueId())
|
||||
_ = c.createPersonalSpaceCache.Delete(spaceid)
|
||||
return resp, nil
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+13
@@ -238,3 +238,16 @@ func (CleanUpload) Unmarshal(v []byte) (interface{}, error) {
|
||||
err := json.Unmarshal(v, &e)
|
||||
return e, err
|
||||
}
|
||||
|
||||
// RevertRevision can be emitted to revert a revision
|
||||
type RevertRevision struct {
|
||||
ResourceID *provider.ResourceId
|
||||
Timestamp *types.Timestamp
|
||||
}
|
||||
|
||||
// Unmarshal to fulfill umarshaller interface
|
||||
func (RevertRevision) Unmarshal(v []byte) (interface{}, error) {
|
||||
e := RevertRevision{}
|
||||
err := json.Unmarshal(v, &e)
|
||||
return e, err
|
||||
}
|
||||
Generated
Vendored
+13
@@ -84,6 +84,7 @@ var (
|
||||
events.RestartPostprocessing{},
|
||||
events.StartPostprocessingStep{},
|
||||
events.CleanUpload{},
|
||||
events.RevertRevision{},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -457,6 +458,18 @@ func (fs *Decomposedfs) Postprocessing(ch <-chan events.Event) {
|
||||
continue // NOTE: since we can't get the upload, we can't delete the blob
|
||||
}
|
||||
session.Cleanup(true, !ev.KeepUpload, !ev.KeepUpload, true)
|
||||
case events.RevertRevision:
|
||||
sublog := log.With().Str("event", "RevertRevision").Interface("nodeid", ev.ResourceID).Logger()
|
||||
n, err := fs.lu.NodeFromID(ctx, ev.ResourceID)
|
||||
if err != nil {
|
||||
sublog.Error().Err(err).Msg("Failed to get node")
|
||||
continue
|
||||
}
|
||||
|
||||
if err := n.RevertCurrentRevision(ctx); err != nil {
|
||||
sublog.Error().Err(err).Msg("Failed to revert revision")
|
||||
continue
|
||||
}
|
||||
case events.StartPostprocessingStep:
|
||||
sublog := log.With().Str("event", "StartPostprocessingStep").Str("uploadid", ev.UploadID).Logger()
|
||||
if ev.UploadID == "" {
|
||||
|
||||
+77
-1
@@ -1324,7 +1324,12 @@ func (n *Node) DeleteGrant(ctx context.Context, g *provider.Grant) (err error) {
|
||||
|
||||
// Purge removes a node from disk. It does not move it to the trash
|
||||
func (n *Node) Purge(ctx context.Context) error {
|
||||
return n.lu.PurgeNode(n)
|
||||
if err := n.lu.PurgeNode(n); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove .mpk and .mlock files
|
||||
return n.lu.MetadataBackend().Purge(ctx, n)
|
||||
}
|
||||
|
||||
// ListGrants lists all grants of the current node.
|
||||
@@ -1551,6 +1556,77 @@ func (n *Node) SetDTime(ctx context.Context, t *time.Time) (err error) {
|
||||
return n.lu.TimeManager().SetDTime(ctx, n, t)
|
||||
}
|
||||
|
||||
// RevertCurrentRevision reverts an upload by either deleting the node or restoring the latest version
|
||||
func (n *Node) RevertCurrentRevision(ctx context.Context) error {
|
||||
versionPath, err := n.getLatestRevision(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if versionPath == "" {
|
||||
// there is no revision - delete the node
|
||||
if err := n.Purge(ctx); err != nil {
|
||||
appctx.GetLogger(ctx).Info().Str("nodepath", n.InternalPath()).Err(err).Msg("error purging node")
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
revisionID := strings.TrimPrefix(versionPath, n.InternalPath()+RevisionIDDelimiter)
|
||||
versionNode := NewBaseNode(n.SpaceID, n.ID+RevisionIDDelimiter+revisionID, n.lu)
|
||||
if err := n.lu.CopyMetadata(ctx, versionNode, n, func(attributeName string, value []byte) (newValue []byte, copy bool) {
|
||||
return value, strings.HasPrefix(attributeName, prefixes.ChecksumPrefix) ||
|
||||
attributeName == prefixes.TypeAttr ||
|
||||
attributeName == prefixes.BlobIDAttr ||
|
||||
attributeName == prefixes.BlobsizeAttr ||
|
||||
attributeName == prefixes.MTimeAttr
|
||||
}); err != nil {
|
||||
appctx.GetLogger(ctx).Info().Str("versionpath", versionPath).Str("nodepath", n.InternalPath()).Err(err).Msg("renaming version node failed")
|
||||
return err
|
||||
}
|
||||
|
||||
if err := os.RemoveAll(versionPath); err != nil {
|
||||
appctx.GetLogger(ctx).Info().Str("versionpath", versionPath).Str("nodepath", n.InternalPath()).Err(err).Msg("error removing version")
|
||||
return err
|
||||
}
|
||||
|
||||
// we just reverted an upload - remove processing flag if set
|
||||
if uploadid, err := n.ProcessingID(ctx); err == nil {
|
||||
if err := n.UnmarkProcessing(ctx, uploadid); err != nil {
|
||||
appctx.GetLogger(ctx).Info().Str("path", n.InternalPath()).Err(err).Msg("unmarking processing failed")
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *Node) getLatestRevision(ctx context.Context) (string, error) {
|
||||
revPrefix := n.InternalPath() + RevisionIDDelimiter
|
||||
revisions, err := filepath.Glob(revPrefix + "*")
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Error().Str("nodepath", n.InternalPath()).Err(err).Msg("error reading revisions")
|
||||
return "", err
|
||||
}
|
||||
|
||||
revPath, latest := "", time.Time{}
|
||||
for _, rev := range revisions {
|
||||
if strings.HasSuffix(rev, ".mpk") || strings.HasSuffix(rev, ".mlock") {
|
||||
continue
|
||||
}
|
||||
revDate, err := time.Parse(time.RFC3339Nano, strings.TrimPrefix(rev, revPrefix))
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Error().Str("nodepath", n.InternalPath()).Err(err).Msg("error parsing revision date")
|
||||
continue
|
||||
}
|
||||
|
||||
if revDate.After(latest) {
|
||||
latest = revDate
|
||||
revPath = rev
|
||||
}
|
||||
}
|
||||
return revPath, nil
|
||||
}
|
||||
|
||||
// ReadChildNodeFromLink reads the child node id from a link
|
||||
func ReadChildNodeFromLink(ctx context.Context, path string) (string, error) {
|
||||
_, span := tracer.Start(ctx, "readChildNodeFromLink")
|
||||
|
||||
Generated
Vendored
+17
-62
@@ -433,72 +433,12 @@ func checkHash(expected string, h hash.Hash) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (session *DecomposedFsSession) removeNode(ctx context.Context) {
|
||||
n, err := session.Node(ctx)
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Error().Str("session", session.ID()).Err(err).Msg("getting node from session failed")
|
||||
return
|
||||
}
|
||||
if err := n.Purge(ctx); err != nil {
|
||||
appctx.GetLogger(ctx).Error().Str("nodepath", n.InternalPath()).Err(err).Msg("purging node failed")
|
||||
}
|
||||
}
|
||||
|
||||
// cleanup cleans up after the upload is finished
|
||||
func (session *DecomposedFsSession) Cleanup(revertNodeMetadata, cleanBin, cleanInfo, unmarkPostprocessing bool) {
|
||||
ctx := session.Context(context.Background())
|
||||
sublog := session.store.log.With().Str("cleanup sessionid", session.ID()).Bool("revertNodeMetadata", revertNodeMetadata).Bool("cleanBin", cleanBin).
|
||||
Bool("cleanInfo", cleanInfo).Bool("unmarkPostprocessing", unmarkPostprocessing).Logger()
|
||||
|
||||
if revertNodeMetadata {
|
||||
n, err := session.Node(ctx)
|
||||
if err != nil {
|
||||
sublog.Error().Err(err).Msg("reading node for session failed")
|
||||
} else {
|
||||
if session.NodeExists() && session.info.MetaData["versionID"] != "" {
|
||||
versionID := session.info.MetaData["versionID"]
|
||||
sublog.Debug().Str("nodepath", n.InternalPath()).Str("versionID", versionID).Msg("restoring revision")
|
||||
revisionNode, err := node.ReadNode(ctx, session.store.lu, session.SpaceID(), versionID, "", false, n.SpaceRoot, false)
|
||||
if err != nil {
|
||||
sublog.Error().Err(err).Str("versionID", versionID).Msg("reading revision node failed")
|
||||
return
|
||||
}
|
||||
|
||||
if !revisionNode.Exists {
|
||||
sublog.Error().Str("versionID", versionID).Msg("revision node does not exist")
|
||||
return
|
||||
}
|
||||
|
||||
// restore the revision
|
||||
mtime, err := revisionNode.GetMTime(ctx)
|
||||
if err != nil {
|
||||
sublog.Error().Err(err).Str("versionID", versionID).Msg("getting mtime of revision node failed")
|
||||
mtime = time.Now()
|
||||
}
|
||||
|
||||
if err := session.store.tp.RestoreRevision(ctx, revisionNode, n, mtime); err != nil {
|
||||
sublog.Error().Err(err).Str("versionID", versionID).Msg("restoring revision node failed")
|
||||
return
|
||||
}
|
||||
|
||||
if err := os.RemoveAll(revisionNode.InternalPath()); err != nil {
|
||||
sublog.Error().Err(err).Str("revisionpath", revisionNode.InternalPath()).Msg("removing restored revision file failed")
|
||||
}
|
||||
} else {
|
||||
// if no other upload session is in progress (processing id != session id) or has finished (processing id == "")
|
||||
latestSession, err := n.ProcessingID(ctx)
|
||||
if err != nil {
|
||||
sublog.Error().Err(err).Str("spaceid", n.SpaceID).Str("nodeid", n.ID).Str("uploadid", session.ID()).Msg("reading processingid for session failed")
|
||||
}
|
||||
if latestSession == session.ID() {
|
||||
// actually delete the node
|
||||
session.removeNode(ctx)
|
||||
}
|
||||
// FIXME else if the upload has become a revision, delete the revision, or if it is the last one, delete the node
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if cleanBin {
|
||||
if err := os.Remove(session.binPath()); err != nil && !errors.Is(err, fs.ErrNotExist) {
|
||||
appctx.GetLogger(ctx).Error().Str("path", session.binPath()).Err(err).Msg("removing upload failed")
|
||||
@@ -508,11 +448,26 @@ func (session *DecomposedFsSession) Cleanup(revertNodeMetadata, cleanBin, cleanI
|
||||
if cleanInfo {
|
||||
if err := os.Remove(session.infoPath()); err != nil {
|
||||
sublog.Error().Err(err).Msg("removing upload info failed")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if unmarkPostprocessing {
|
||||
if revertNodeMetadata {
|
||||
n, err := session.Node(ctx)
|
||||
if err != nil {
|
||||
sublog.Error().Err(err).Msg("reading node for session failed")
|
||||
return
|
||||
}
|
||||
|
||||
curUpload, err := n.ProcessingID(ctx)
|
||||
if err == nil && curUpload == session.ID() {
|
||||
if err := n.RevertCurrentRevision(ctx); err != nil {
|
||||
sublog.Error().Err(err).Str("nodepath", n.InternalPath()).Msg("reverting node metadata failed")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if unmarkPostprocessing && !revertNodeMetadata { // node reverting automatically unmarks processing
|
||||
n, err := session.Node(ctx)
|
||||
if err != nil {
|
||||
sublog.Info().Err(err).Msg("could not read node")
|
||||
|
||||
Generated
Vendored
+13
@@ -84,6 +84,7 @@ var (
|
||||
events.PostprocessingStepFinished{},
|
||||
events.RestartPostprocessing{},
|
||||
events.CleanUpload{},
|
||||
events.RevertRevision{},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -445,6 +446,18 @@ func (fs *Decomposedfs) Postprocessing(ch <-chan events.Event) {
|
||||
continue // NOTE: since we can't get the upload, we can't delete the blob
|
||||
}
|
||||
session.Cleanup(true, !ev.KeepUpload, !ev.KeepUpload, true)
|
||||
case events.RevertRevision:
|
||||
sublog := log.With().Str("event", "RevertRevision").Interface("nodeid", ev.ResourceID).Logger()
|
||||
n, err := fs.lu.NodeFromID(ctx, ev.ResourceID)
|
||||
if err != nil {
|
||||
sublog.Error().Err(err).Msg("Failed to get node")
|
||||
continue
|
||||
}
|
||||
|
||||
if err := n.RevertCurrentRevision(ctx); err != nil {
|
||||
sublog.Error().Err(err).Msg("Failed to revert revision")
|
||||
continue
|
||||
}
|
||||
case events.PostprocessingStepFinished:
|
||||
sublog := log.With().Str("event", "PostprocessingStepFinished").Str("uploadid", ev.UploadID).Logger()
|
||||
if ev.FinishedStep != events.PPStepAntivirus {
|
||||
|
||||
Generated
Vendored
+77
-1
@@ -1165,7 +1165,12 @@ func (n *Node) Purge(ctx context.Context) error {
|
||||
|
||||
// remove child entry in parent
|
||||
src := filepath.Join(n.ParentPath(), n.Name)
|
||||
return os.Remove(src)
|
||||
if err := os.Remove(src); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove .mpk and .mlock files
|
||||
return n.lu.MetadataBackend().Purge(ctx, n.InternalPath())
|
||||
}
|
||||
|
||||
// ListGrants lists all grants of the current node.
|
||||
@@ -1391,3 +1396,74 @@ func (n *Node) GetDTime(ctx context.Context) (time.Time, error) {
|
||||
func (n *Node) SetDTime(ctx context.Context, t *time.Time) (err error) {
|
||||
return n.lu.TimeManager().SetDTime(ctx, n, t)
|
||||
}
|
||||
|
||||
// RevertCurrentRevision reverts an upload by either deleting the node or restoring the latest version
|
||||
func (n *Node) RevertCurrentRevision(ctx context.Context) error {
|
||||
versionPath, err := n.getLatestRevision(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if versionPath == "" {
|
||||
// there is no revision - delete the node
|
||||
if err := n.Purge(ctx); err != nil {
|
||||
appctx.GetLogger(ctx).Info().Str("nodepath", n.InternalPath()).Err(err).Msg("error purging node")
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := n.lu.CopyMetadata(ctx, versionPath, n.InternalPath(), func(attributeName string, value []byte) (newValue []byte, copy bool) {
|
||||
return value, strings.HasPrefix(attributeName, prefixes.ChecksumPrefix) ||
|
||||
attributeName == prefixes.TypeAttr ||
|
||||
attributeName == prefixes.BlobIDAttr ||
|
||||
attributeName == prefixes.BlobsizeAttr ||
|
||||
attributeName == prefixes.MTimeAttr
|
||||
}, true); err != nil {
|
||||
appctx.GetLogger(ctx).Info().Str("versionpath", versionPath).Str("nodepath", n.InternalPath()).Err(err).Msg("renaming version node failed")
|
||||
return err
|
||||
}
|
||||
|
||||
if err := os.RemoveAll(versionPath); err != nil {
|
||||
appctx.GetLogger(ctx).Info().Str("versionpath", versionPath).Str("nodepath", n.InternalPath()).Err(err).Msg("error removing version")
|
||||
return err
|
||||
}
|
||||
|
||||
// we just reverted an upload - remove processing flag if set
|
||||
if uploadid, err := n.ProcessingID(ctx); err == nil {
|
||||
if err := n.UnmarkProcessing(ctx, uploadid); err != nil {
|
||||
appctx.GetLogger(ctx).Info().Str("path", n.InternalPath()).Err(err).Msg("unmarking processing failed")
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func (n *Node) getLatestRevision(ctx context.Context) (string, error) {
|
||||
revPrefix := n.InternalPath() + RevisionIDDelimiter
|
||||
revisions, err := filepath.Glob(revPrefix + "*")
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Error().Str("nodepath", n.InternalPath()).Err(err).Msg("error reading revisions")
|
||||
return "", err
|
||||
}
|
||||
|
||||
revPath, latest := "", time.Time{}
|
||||
for _, rev := range revisions {
|
||||
if strings.HasSuffix(rev, ".mpk") || strings.HasSuffix(rev, ".mlock") {
|
||||
continue
|
||||
}
|
||||
revDate, err := time.Parse(time.RFC3339Nano, strings.TrimPrefix(rev, revPrefix))
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Error().Str("nodepath", n.InternalPath()).Err(err).Msg("error parsing revision date")
|
||||
continue
|
||||
}
|
||||
|
||||
appctx.GetLogger(ctx).Error().Str("nodepath", n.InternalPath()).Str("revPath", revPath).Interface("time", revDate).Err(err).Msg("error parsing revision date")
|
||||
if revDate.After(latest) {
|
||||
latest = revDate
|
||||
revPath = rev
|
||||
}
|
||||
}
|
||||
return revPath, nil
|
||||
}
|
||||
Generated
Vendored
+17
-49
@@ -316,57 +316,10 @@ func checkHash(expected string, h hash.Hash) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (session *OcisSession) removeNode(ctx context.Context) {
|
||||
n, err := session.Node(ctx)
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Error().Str("session", session.ID()).Err(err).Msg("getting node from session failed")
|
||||
return
|
||||
}
|
||||
if err := n.Purge(ctx); err != nil {
|
||||
appctx.GetLogger(ctx).Error().Str("nodepath", n.InternalPath()).Err(err).Msg("purging node failed")
|
||||
}
|
||||
}
|
||||
|
||||
// cleanup cleans up after the upload is finished
|
||||
func (session *OcisSession) Cleanup(revertNodeMetadata, cleanBin, cleanInfo, unmarkPostprocessing bool) {
|
||||
ctx := session.Context(context.Background())
|
||||
|
||||
if revertNodeMetadata {
|
||||
n, err := session.Node(ctx)
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("sessionid", session.ID()).Msg("reading node for session failed")
|
||||
} else {
|
||||
if session.NodeExists() && session.info.MetaData["versionsPath"] != "" {
|
||||
p := session.info.MetaData["versionsPath"]
|
||||
if err := session.store.lu.CopyMetadata(ctx, p, n.InternalPath(), func(attributeName string, value []byte) (newValue []byte, copy bool) {
|
||||
return value, strings.HasPrefix(attributeName, prefixes.ChecksumPrefix) ||
|
||||
attributeName == prefixes.TypeAttr ||
|
||||
attributeName == prefixes.BlobIDAttr ||
|
||||
attributeName == prefixes.BlobsizeAttr ||
|
||||
attributeName == prefixes.MTimeAttr
|
||||
}, true); err != nil {
|
||||
appctx.GetLogger(ctx).Info().Str("versionpath", p).Str("nodepath", n.InternalPath()).Err(err).Msg("renaming version node failed")
|
||||
}
|
||||
|
||||
if err := os.RemoveAll(p); err != nil {
|
||||
appctx.GetLogger(ctx).Info().Str("versionpath", p).Str("nodepath", n.InternalPath()).Err(err).Msg("error removing version")
|
||||
}
|
||||
|
||||
} else {
|
||||
// if no other upload session is in progress (processing id != session id) or has finished (processing id == "")
|
||||
latestSession, err := n.ProcessingID(ctx)
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("spaceid", n.SpaceID).Str("nodeid", n.ID).Str("uploadid", session.ID()).Msg("reading processingid for session failed")
|
||||
}
|
||||
if latestSession == session.ID() {
|
||||
// actually delete the node
|
||||
session.removeNode(ctx)
|
||||
}
|
||||
// FIXME else if the upload has become a revision, delete the revision, or if it is the last one, delete the node
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if cleanBin {
|
||||
if err := os.Remove(session.binPath()); err != nil && !errors.Is(err, fs.ErrNotExist) {
|
||||
appctx.GetLogger(ctx).Error().Str("path", session.binPath()).Err(err).Msg("removing upload failed")
|
||||
@@ -376,11 +329,26 @@ func (session *OcisSession) Cleanup(revertNodeMetadata, cleanBin, cleanInfo, unm
|
||||
if cleanInfo {
|
||||
if err := os.Remove(session.infoPath()); err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("session", session.ID()).Msg("removing upload info failed")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if unmarkPostprocessing {
|
||||
if revertNodeMetadata {
|
||||
n, err := session.Node(ctx)
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("sessionid", session.ID()).Msg("reading node for session failed")
|
||||
return
|
||||
}
|
||||
|
||||
curUpload, err := n.ProcessingID(ctx)
|
||||
if err == nil && curUpload == session.ID() {
|
||||
if err := n.RevertCurrentRevision(ctx); err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("nodepath", n.InternalPath()).Msg("reverting node metadata failed")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if unmarkPostprocessing && !revertNodeMetadata { // node reverting automatically unmarks processing
|
||||
n, err := session.Node(ctx)
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Info().Str("session", session.ID()).Err(err).Msg("could not read node")
|
||||
|
||||
Vendored
+1
-1
@@ -1338,7 +1338,7 @@ github.com/opencloud-eu/icap-client
|
||||
# github.com/opencloud-eu/libre-graph-api-go v1.0.8-0.20260902170011-45af3945a067
|
||||
## explicit; go 1.23
|
||||
github.com/opencloud-eu/libre-graph-api-go
|
||||
# github.com/opencloud-eu/reva/v2 v2.50.1-0.20260924091259-7fa82c610dba
|
||||
# github.com/opencloud-eu/reva/v2 v2.50.1-0.20260924114030-295fe643704f
|
||||
## explicit; go 1.26.0
|
||||
github.com/opencloud-eu/reva/v2/cmd/revad/internal/grace
|
||||
github.com/opencloud-eu/reva/v2/cmd/revad/runtime
|
||||
|
||||
Reference in new issue
Block a user