Skip to content

Commit

Permalink
update expected failures, continue propagating on minor errors
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Feb 3, 2021
1 parent 0336464 commit 9326e3b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 33 deletions.
51 changes: 21 additions & 30 deletions pkg/storage/fs/ocis/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/pkg/xattr"
"github.com/rs/zerolog/log"
)

// Tree manages a hierarchical tree
Expand Down Expand Up @@ -301,12 +300,12 @@ func (t *Tree) Delete(ctx context.Context, n *Node) (err error) {

// Propagate propagates changes to the root of the tree
func (t *Tree) Propagate(ctx context.Context, n *Node) (err error) {
sublog := appctx.GetLogger(ctx).With().Interface("node", n).Logger()
if !t.lu.Options.TreeTimeAccounting && !t.lu.Options.TreeSizeAccounting {
// no propagation enabled
log.Debug().Msg("propagation disabled")
sublog.Debug().Msg("propagation disabled")
return
}
log := appctx.GetLogger(ctx)

// is propagation enabled for the parent node?

Expand All @@ -320,16 +319,18 @@ func (t *Tree) Propagate(ctx context.Context, n *Node) (err error) {

// we loop until we reach the root
for err == nil && n.ID != root.ID {
log.Debug().Interface("node", n).Msg("propagating")
sublog.Debug().Msg("propagating")

// make n the parent or break the loop
if n, err = n.Parent(); err != nil {
break
}

sublog = sublog.With().Interface("node", n).Logger()

// TODO none, sync and async?
if !n.HasPropagation() {
log.Debug().Interface("node", n).Str("attr", propagationAttr).Msg("propagation attribute not set or unreadable, not propagating")
sublog.Debug().Str("attr", propagationAttr).Msg("propagation attribute not set or unreadable, not propagating")
// if the attribute is not set treat it as false / none / no propagation
return nil
}
Expand All @@ -343,20 +344,16 @@ func (t *Tree) Propagate(ctx context.Context, n *Node) (err error) {
switch {
case err != nil:
// missing attribute, or invalid format, overwrite
log.Debug().Err(err).
Interface("node", n).
Msg("could not read tmtime attribute, overwriting")
sublog.Debug().Err(err).Msg("could not read tmtime attribute, overwriting")
updateSyncTime = true
case tmTime.Before(sTime):
log.Debug().
Interface("node", n).
sublog.Debug().
Time("tmtime", tmTime).
Time("stime", sTime).
Msg("parent tmtime is older than node mtime, updating")
updateSyncTime = true
default:
log.Debug().
Interface("node", n).
sublog.Debug().
Time("tmtime", tmTime).
Time("stime", sTime).
Dur("delta", sTime.Sub(tmTime)).
Expand All @@ -366,14 +363,14 @@ func (t *Tree) Propagate(ctx context.Context, n *Node) (err error) {
if updateSyncTime {
// update the tree time of the parent node
if err = n.SetTMTime(sTime); err != nil {
log.Error().Err(err).Interface("node", n).Time("tmtime", sTime).Msg("could not update tmtime of parent node")
return
sublog.Error().Err(err).Time("tmtime", sTime).Msg("could not update tmtime of parent node")
} else {
sublog.Debug().Time("tmtime", sTime).Msg("updated tmtime of parent node")
}
log.Debug().Interface("node", n).Time("tmtime", sTime).Msg("updated tmtime of parent node")
}

if err := n.UnsetTempEtag(); err != nil {
log.Error().Err(err).Interface("node", n).Msg("could not remove temporary etag attribute")
sublog.Error().Err(err).Msg("could not remove temporary etag attribute")
}

}
Expand All @@ -386,27 +383,23 @@ func (t *Tree) Propagate(ctx context.Context, n *Node) (err error) {
var treeSize, calculatedTreeSize uint64
calculatedTreeSize, err = n.CalculateTreeSize(ctx)
if err != nil {
return
continue
}

treeSize, err = n.GetTreeSize()
switch {
case err != nil:
// missing attribute, or invalid format, overwrite
log.Debug().Err(err).
Interface("node", n).
Msg("could not read treesize attribute, overwriting")
sublog.Debug().Err(err).Msg("could not read treesize attribute, overwriting")
updateTreeSize = true
case treeSize != calculatedTreeSize:
log.Debug().
Interface("node", n).
sublog.Debug().
Uint64("treesize", treeSize).
Uint64("calculatedTreeSize", calculatedTreeSize).
Msg("parent treesize is different then calculated treesize, updating")
updateTreeSize = true
default:
log.Debug().
Interface("node", n).
sublog.Debug().
Uint64("treesize", treeSize).
Uint64("calculatedTreeSize", calculatedTreeSize).
Msg("parent size matches calculated size, not updating")
Expand All @@ -415,17 +408,15 @@ func (t *Tree) Propagate(ctx context.Context, n *Node) (err error) {
if updateTreeSize {
// update the tree time of the parent node
if err = n.SetTreeSize(calculatedTreeSize); err != nil {
log.Error().Err(err).Interface("node", n).Uint64("calculatedTreeSize", calculatedTreeSize).Msg("could not update treesize of parent node")
return
sublog.Error().Err(err).Uint64("calculatedTreeSize", calculatedTreeSize).Msg("could not update treesize of parent node")
} else {
sublog.Debug().Uint64("calculatedTreeSize", calculatedTreeSize).Msg("updated treesize of parent node")
}
log.Debug().Interface("node", n).Uint64("calculatedTreeSize", calculatedTreeSize).Msg("updated treesize of parent node")
}
}

}
if err != nil {
log.Error().Err(err).Interface("node", n).Msg("error propagating")
return
sublog.Error().Err(err).Msg("error propagating")
}
return
}
3 changes: 0 additions & 3 deletions tests/acceptance/expected-failures-on-OCIS-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,6 @@ Scenario Outline: try to create a folder with a name of an existing file
### [Different webdav properties from core](https://github.com/owncloud/ocis/issues/1302)
- [apiWebdavProperties2/getFileProperties.feature:327](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties2/getFileProperties.feature#L327)
- [apiWebdavProperties2/getFileProperties.feature:328](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties2/getFileProperties.feature#L328)
Scenario Outline: Propfind the size of a folder using webdav api `Property "oc:size" found with value "10", expected "#^0$#" or "#^0$#"`
- [apiWebdavProperties2/getFileProperties.feature:376](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties2/getFileProperties.feature#L376)
- [apiWebdavProperties2/getFileProperties.feature:377](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties2/getFileProperties.feature#L377)
Scenario Outline: Propfind the permissions on a file using webdav api `Property "oc:permissions" found with value "DNVWR", expected "/RM{0,1}DNVW/"`
- [apiWebdavProperties2/getFileProperties.feature:441](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties2/getFileProperties.feature#L441)
- [apiWebdavProperties2/getFileProperties.feature:442](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties2/getFileProperties.feature#L442)
Expand Down

0 comments on commit 9326e3b

Please sign in to comment.