Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c29cddcca0 |
No files matched your search
@@ -1,10 +0,0 @@
|
||||
Bugfix: Remove keyboard focus from open file name in top bar
|
||||
|
||||
When opening a file such as a text or markdown document, the file name shown
|
||||
in the top bar could be reached via keyboard tabbing even though it was not
|
||||
clickable and triggered no action. This made keyboard navigation confusing.
|
||||
|
||||
The file name is no longer part of the tab order, since it is a purely
|
||||
informational, non-interactive element.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12752
|
||||
@@ -1,14 +0,0 @@
|
||||
Bugfix: Truncate long resource names instead of overlapping the next column
|
||||
|
||||
In resource tables, a name that was too long for its column was not truncated.
|
||||
Instead it kept its full width and was painted over the value of the adjacent
|
||||
column, making both unreadable. This was most visible in the Spaces overview,
|
||||
where a long space name overlapped the "Manager" column, but it affected every
|
||||
resource table using the name column, including the files list and search
|
||||
results, as well as the parent folder path shown below a search result.
|
||||
|
||||
The name is now truncated with an ellipsis at the column boundary, and the
|
||||
rename button stays inside the name column. The full name remains available via
|
||||
the title tooltip on hover.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12754
|
||||
@@ -1,21 +0,0 @@
|
||||
Enhancement: Add a command to recalculate the treesize of a space
|
||||
|
||||
The reported quota usage of a space can drift from the data actually stored on
|
||||
disk. The treesize of a directory is maintained as a running counter that is
|
||||
updated on every change, so a failed or incomplete update leaves the counter
|
||||
wrong. Removing a node without propagating the size change, for example, leaves
|
||||
its size counted against the quota forever, with no way to reclaim it.
|
||||
|
||||
The new command walks a space bottom up, recalculates the treesize of every
|
||||
directory from the actual size of its children and corrects the stored values:
|
||||
|
||||
```
|
||||
ocis storage-users spaces recalculate-treesize --space-id <id>
|
||||
ocis storage-users spaces recalculate-treesize --space-id <id> --dry-run=false
|
||||
```
|
||||
|
||||
Omit `--space-id` to process all spaces. As with the other maintenance commands,
|
||||
`--dry-run` defaults to true, so the command reports what it would change until
|
||||
it is explicitly told to write.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12746
|
||||
@@ -1,17 +0,0 @@
|
||||
Bugfix: Open files whose name contains a hash or question mark
|
||||
|
||||
Cmd+Clicking or middle-clicking a file with a `#` or `?` in its name opened the
|
||||
space root instead of the file, and the top bar showed the space name rather than
|
||||
the file name. The file's path is carried in a route parameter which the router
|
||||
percent-encodes when it builds the URL, but the editor route was resolved twice
|
||||
and resolving twice does not encode twice: the second pass rebuilt the URL from
|
||||
the still-decoded parameter with the encoding step skipped. The browser then read
|
||||
everything from the `#` onward as a fragment, discarding the query string along
|
||||
with the `fileId` needed to identify the file. Left clicks were unaffected because
|
||||
they never leave the app.
|
||||
|
||||
Editor routes are now handed to links unresolved, so the file name is encoded
|
||||
exactly once and survives both a new tab and an in-app navigation. Hash and
|
||||
question mark remain valid characters in file names.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12740
|
||||
@@ -67,7 +67,7 @@ require (
|
||||
github.com/open-policy-agent/opa v1.19.0
|
||||
github.com/orcaman/concurrent-map v1.0.0
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260806084131-831afd01e5d4
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260807095944-8056f5e1297e
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/pkg/xattr v0.4.12
|
||||
github.com/prometheus/client_golang v1.24.1
|
||||
|
||||
@@ -736,8 +736,8 @@ github.com/orcaman/concurrent-map v1.0.0 h1:I/2A2XPCb4IuQWcQhBhSwGfiuybl/J0ev9HD
|
||||
github.com/orcaman/concurrent-map v1.0.0/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245 h1:JRidLTAKhnvyLMRtVtSF4lhBa0NSAOs6fof+d6JnKII=
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245/go.mod h1:z61VMGAJRtR1nbgXWiNoCkxUXP1B3Je9rMuJbnGd+Og=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260806084131-831afd01e5d4 h1:Cnq24qhteHD30DfTG8o0bf3cnVL/2b+afz//0qGjAeU=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260806084131-831afd01e5d4/go.mod h1:XBnHPPDOGYq+Uf/PD1wGXne3xTvoghBxXPUULcSZjlc=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260807095944-8056f5e1297e h1:VyezYtf9tz6COz9sIk2i2szESueBPTI79KEOSR8I8Ug=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260807095944-8056f5e1297e/go.mod h1:XBnHPPDOGYq+Uf/PD1wGXne3xTvoghBxXPUULcSZjlc=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
|
||||
github.com/pablodz/inotifywaitgo v0.0.12 h1:DVJJTFMDlSAdO46yisPF2vzozs/r+4k6ih8MVghq78M=
|
||||
|
||||
@@ -181,45 +181,6 @@ OPTIONS:
|
||||
--help, -h show help
|
||||
```
|
||||
|
||||
Note that removing a stale node does not reclaim the quota it consumed. Use the
|
||||
Recalculate Treesize command afterwards to correct the reported quota usage of the space.
|
||||
|
||||
#### Recalculate Treesize command
|
||||
|
||||
The treesize of a directory is maintained as a running counter that is updated on every
|
||||
change, so a failed or incomplete update leaves the counter wrong and the reported quota
|
||||
usage of a space drifts from the data actually stored on disk. This command walks a space
|
||||
bottom up, recalculates the treesize of every directory from the actual size of its
|
||||
children and corrects the stored values.
|
||||
|
||||
```bash
|
||||
~/ocis storage-users spaces recalculate-treesize <commandoptions>
|
||||
```
|
||||
```
|
||||
NAME:
|
||||
ocis storage-users spaces recalculate-treesize - Recalculate the treesize of all directories in a space from the actual size of their children. Use this to repair a space whose reported quota usage drifted from the data on disk
|
||||
|
||||
USAGE:
|
||||
ocis storage-users spaces recalculate-treesize [command options]
|
||||
|
||||
OPTIONS:
|
||||
--space-id value, -s value Space ID to recalculate (omit to process all spaces)
|
||||
--dry-run Only show which treesizes would be corrected without writing them (default: true)
|
||||
--verbose, -v Enable verbose logging (default: false)
|
||||
--help, -h show help
|
||||
```
|
||||
|
||||
```bash
|
||||
# report incorrect treesizes of a single space without changing anything
|
||||
ocis storage-users spaces recalculate-treesize --space-id 43972c79-f7ce-441b-9fe0-cf5170e4d61e
|
||||
|
||||
# correct them
|
||||
ocis storage-users spaces recalculate-treesize --space-id 43972c79-f7ce-441b-9fe0-cf5170e4d61e --dry-run=false
|
||||
```
|
||||
|
||||
Note: the command reads the metadata of every node in the space, so it is I/O intensive on
|
||||
large spaces. Prefer targeting a single space with `--space-id` over processing all spaces.
|
||||
|
||||
#### Command Examples
|
||||
|
||||
Dry run to see what would be deleted (recommended first step)
|
||||
|
||||
@@ -33,7 +33,6 @@ func Spaces(cfg *config.Config) *cli.Command {
|
||||
Usage: "manage spaces",
|
||||
Subcommands: []*cli.Command{
|
||||
PurgeDisabledSpaces(cfg),
|
||||
RecalculateTreesize(cfg),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,222 +0,0 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
"github.com/olekukonko/tablewriter"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/config/configlog"
|
||||
"github.com/owncloud/ocis/v2/services/storage-users/pkg/config"
|
||||
"github.com/owncloud/ocis/v2/services/storage-users/pkg/config/parser"
|
||||
"github.com/owncloud/reva/v2/pkg/storage/utils/decomposedfs/lookup"
|
||||
"github.com/owncloud/reva/v2/pkg/storage/utils/decomposedfs/metadata/prefixes"
|
||||
"github.com/shamaton/msgpack/v2"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// metadataExtension is the suffix of the messagepack metadata file of a node
|
||||
const metadataExtension = ".mpk"
|
||||
|
||||
// RecalculateTreesize is the entry point for the recalculate-treesize command
|
||||
func RecalculateTreesize(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "recalculate-treesize",
|
||||
Usage: "Recalculate the treesize of all directories in a space from the actual size of their children. " +
|
||||
"Use this to repair a space whose reported quota usage drifted from the data on disk",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "space-id",
|
||||
Usage: "Space ID to recalculate (omit to process all spaces)",
|
||||
Required: false,
|
||||
Aliases: []string{"s"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "dry-run",
|
||||
Usage: "Only show which treesizes would be corrected without writing them",
|
||||
Value: true, // default must be true to avoid accidental writes!
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "verbose",
|
||||
Usage: "Enable verbose logging",
|
||||
Value: false,
|
||||
Aliases: []string{"v"},
|
||||
},
|
||||
},
|
||||
Before: func(c *cli.Context) error {
|
||||
return configlog.ReturnFatal(parser.ParseConfig(cfg))
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
dryRun := c.Bool("dry-run")
|
||||
verbose := c.Bool("verbose")
|
||||
|
||||
spaceIDs := []string{}
|
||||
if c.IsSet("space-id") {
|
||||
spaceIDs = append(spaceIDs, c.String("space-id"))
|
||||
} else {
|
||||
fmt.Println("Scanning all spaces for incorrect treesizes...")
|
||||
spaceIDs = globSpaceIDs(cfg)
|
||||
}
|
||||
|
||||
if dryRun {
|
||||
fmt.Print("Dry run mode enabled, no treesize will be written\n\n")
|
||||
}
|
||||
|
||||
var (
|
||||
table *tablewriter.Table
|
||||
corrected int
|
||||
)
|
||||
table = tablewriter.NewTable(os.Stdout)
|
||||
table.Header("Space", "Node", "Stored", "Calculated", "Difference")
|
||||
|
||||
for _, spaceID := range spaceIDs {
|
||||
if verbose {
|
||||
fmt.Printf("Recalculating treesizes for space: %s\n", spaceID)
|
||||
}
|
||||
root := filepath.Join(cfg.Drivers.OCIS.Root, "spaces", lookup.Pathify(spaceID, 1, 2), "nodes", lookup.Pathify(spaceID, 4, 2))
|
||||
_, n, err := recalculateNode(cfg, spaceID, root, dryRun, verbose, table)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error recalculating space %s: %s\n", spaceID, err)
|
||||
continue
|
||||
}
|
||||
corrected += n
|
||||
}
|
||||
|
||||
if corrected > 0 {
|
||||
table.Render()
|
||||
}
|
||||
|
||||
switch {
|
||||
case corrected == 0:
|
||||
fmt.Println("All treesizes are correct")
|
||||
case dryRun:
|
||||
fmt.Printf("Would correct %d treesizes. Run with --dry-run=false to apply\n", corrected)
|
||||
default:
|
||||
fmt.Printf("Corrected %d treesizes\n", corrected)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// recalculateNode calculates the size of the node at the given path. For directories it
|
||||
// recurses into the children first, so the whole subtree is corrected bottom up, and
|
||||
// compares the sum against the stored treesize. It returns the calculated size of the
|
||||
// node and the number of corrected treesizes in the subtree.
|
||||
func recalculateNode(cfg *config.Config, spaceID, path string, dryRun, verbose bool, table *tablewriter.Table) (uint64, int, error) {
|
||||
attribs, err := readAttributes(path)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
// Files simply report their blobsize, there is nothing to recalculate. Only an
|
||||
// explicit file type is treated as a file, everything else is walked as a
|
||||
// directory: a space root for example carries no type attribute at all. This
|
||||
// matches how the propagator classifies children.
|
||||
if string(attribs[prefixes.TypeAttr]) == strconv.FormatUint(uint64(provider.ResourceType_RESOURCE_TYPE_FILE), 10) {
|
||||
size, err := strconv.ParseUint(string(attribs[prefixes.BlobsizeAttr]), 10, 64)
|
||||
if err != nil {
|
||||
// a node without a blobsize contributes nothing, but it is worth reporting
|
||||
if verbose {
|
||||
fmt.Fprintf(os.Stderr, " Could not read blobsize of %s: %s\n", path, err)
|
||||
}
|
||||
return 0, 0, nil
|
||||
}
|
||||
return size, 0, nil
|
||||
}
|
||||
|
||||
entries, err := os.ReadDir(path)
|
||||
if err != nil {
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return 0, 0, nil
|
||||
}
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
var (
|
||||
calculated uint64
|
||||
corrected int
|
||||
)
|
||||
for _, entry := range entries {
|
||||
child, err := filepath.EvalSymlinks(filepath.Join(path, entry.Name()))
|
||||
if err != nil {
|
||||
// dangling child entry, it contributes nothing
|
||||
if verbose {
|
||||
fmt.Fprintf(os.Stderr, " Could not resolve child %s: %s\n", entry.Name(), err)
|
||||
}
|
||||
continue
|
||||
}
|
||||
size, n, err := recalculateNode(cfg, spaceID, child, dryRun, verbose, table)
|
||||
if err != nil {
|
||||
if verbose {
|
||||
fmt.Fprintf(os.Stderr, " Could not recalculate child %s: %s\n", child, err)
|
||||
}
|
||||
continue
|
||||
}
|
||||
calculated += size
|
||||
corrected += n
|
||||
}
|
||||
|
||||
stored, storedErr := strconv.ParseUint(string(attribs[prefixes.TreesizeAttr]), 10, 64)
|
||||
if storedErr == nil && stored == calculated {
|
||||
return calculated, corrected, nil
|
||||
}
|
||||
|
||||
storedStr := string(attribs[prefixes.TreesizeAttr])
|
||||
if storedStr == "" {
|
||||
storedStr = "unset"
|
||||
}
|
||||
diff := "n/a"
|
||||
if storedErr == nil {
|
||||
diff = fmt.Sprintf("%+d", int64(calculated)-int64(stored))
|
||||
}
|
||||
table.Append([]string{spaceID, nodeIDFromPath(path), storedStr, strconv.FormatUint(calculated, 10), diff})
|
||||
corrected++
|
||||
|
||||
if !dryRun {
|
||||
if err := writeTreesize(path, attribs, calculated); err != nil {
|
||||
return calculated, corrected, fmt.Errorf("could not write treesize of %s: %w", path, err)
|
||||
}
|
||||
}
|
||||
|
||||
return calculated, corrected, nil
|
||||
}
|
||||
|
||||
// readAttributes reads the messagepack metadata of the node at the given path
|
||||
func readAttributes(path string) (map[string][]byte, error) {
|
||||
b, err := os.ReadFile(path + metadataExtension)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
attribs := map[string][]byte{}
|
||||
if err := msgpack.Unmarshal(b, &attribs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return attribs, nil
|
||||
}
|
||||
|
||||
// writeTreesize sets the treesize attribute of the node at the given path
|
||||
func writeTreesize(path string, attribs map[string][]byte, size uint64) error {
|
||||
attribs[prefixes.TreesizeAttr] = []byte(strconv.FormatUint(size, 10))
|
||||
b, err := msgpack.Marshal(attribs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(path+metadataExtension, b, 0600)
|
||||
}
|
||||
|
||||
// nodeIDFromPath rebuilds the node id from a pathified node path, i.e.
|
||||
// .../nodes/5b/ba/1e/a7/-f185-4f31-8342-ed4b5743f096 -> 5bba1ea7-f185-4f31-8342-ed4b5743f096
|
||||
func nodeIDFromPath(path string) string {
|
||||
parts := strings.Split(path, string(filepath.Separator))
|
||||
if len(parts) < 5 {
|
||||
return path
|
||||
}
|
||||
return strings.Join(parts[len(parts)-5:], "")
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
"github.com/olekukonko/tablewriter"
|
||||
"github.com/owncloud/reva/v2/pkg/storage/utils/decomposedfs/metadata/prefixes"
|
||||
"github.com/shamaton/msgpack/v2"
|
||||
"github.com/test-go/testify/require"
|
||||
)
|
||||
|
||||
// writeNode creates a node file with the given attributes on disk
|
||||
func writeNode(t *testing.T, path string, attribs map[string][]byte) {
|
||||
t.Helper()
|
||||
require.NoError(t, os.MkdirAll(filepath.Dir(path), 0700))
|
||||
b, err := msgpack.Marshal(attribs)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, os.WriteFile(path+metadataExtension, b, 0600))
|
||||
}
|
||||
|
||||
// writeFileNode creates a file node with the given blobsize. The node file itself
|
||||
// has to exist as well, decomposedfs resolves children through it.
|
||||
func writeFileNode(t *testing.T, path string, blobsize int) {
|
||||
t.Helper()
|
||||
writeNode(t, path, map[string][]byte{
|
||||
prefixes.TypeAttr: []byte(strconv.FormatUint(uint64(provider.ResourceType_RESOURCE_TYPE_FILE), 10)),
|
||||
prefixes.BlobsizeAttr: []byte(strconv.Itoa(blobsize)),
|
||||
})
|
||||
require.NoError(t, os.WriteFile(path, []byte{}, 0600))
|
||||
}
|
||||
|
||||
// writeDirNode creates a directory node with the given stored treesize
|
||||
func writeDirNode(t *testing.T, path string, treesize int) {
|
||||
t.Helper()
|
||||
require.NoError(t, os.MkdirAll(path, 0700))
|
||||
writeNode(t, path, map[string][]byte{
|
||||
prefixes.TypeAttr: []byte(strconv.FormatUint(uint64(provider.ResourceType_RESOURCE_TYPE_CONTAINER), 10)),
|
||||
prefixes.TreesizeAttr: []byte(strconv.Itoa(treesize)),
|
||||
})
|
||||
}
|
||||
|
||||
// storedTreesize reads back the treesize attribute of a node
|
||||
func storedTreesize(t *testing.T, path string) string {
|
||||
t.Helper()
|
||||
attribs, err := readAttributes(path)
|
||||
require.NoError(t, err)
|
||||
return string(attribs[prefixes.TreesizeAttr])
|
||||
}
|
||||
|
||||
// linkChild links a child node into a parent directory, mirroring how decomposedfs
|
||||
// references children by symlink
|
||||
func linkChild(t *testing.T, parent, child, name string) {
|
||||
t.Helper()
|
||||
rel, err := filepath.Rel(parent, child)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, os.Symlink(rel, filepath.Join(parent, name)))
|
||||
}
|
||||
|
||||
func TestRecalculateNode(t *testing.T) {
|
||||
t.Run("corrects a wrong treesize", func(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
dir := filepath.Join(root, "dir")
|
||||
writeDirNode(t, dir, 999)
|
||||
f := filepath.Join(root, "file")
|
||||
writeFileNode(t, f, 100)
|
||||
linkChild(t, dir, f, "file")
|
||||
|
||||
size, corrected, err := recalculateNode(nil, "spaceid", dir, false, false, tablewriter.NewTable(os.Stdout))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, uint64(100), size)
|
||||
require.Equal(t, 1, corrected)
|
||||
require.Equal(t, "100", storedTreesize(t, dir))
|
||||
})
|
||||
|
||||
t.Run("leaves a correct treesize untouched", func(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
dir := filepath.Join(root, "dir")
|
||||
writeDirNode(t, dir, 100)
|
||||
f := filepath.Join(root, "file")
|
||||
writeFileNode(t, f, 100)
|
||||
linkChild(t, dir, f, "file")
|
||||
|
||||
size, corrected, err := recalculateNode(nil, "spaceid", dir, false, false, tablewriter.NewTable(os.Stdout))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, uint64(100), size)
|
||||
require.Equal(t, 0, corrected)
|
||||
})
|
||||
|
||||
t.Run("does not write in dry-run mode", func(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
dir := filepath.Join(root, "dir")
|
||||
writeDirNode(t, dir, 999)
|
||||
f := filepath.Join(root, "file")
|
||||
writeFileNode(t, f, 100)
|
||||
linkChild(t, dir, f, "file")
|
||||
|
||||
size, corrected, err := recalculateNode(nil, "spaceid", dir, true, false, tablewriter.NewTable(os.Stdout))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, uint64(100), size)
|
||||
require.Equal(t, 1, corrected)
|
||||
require.Equal(t, "999", storedTreesize(t, dir), "dry-run must not write the treesize")
|
||||
})
|
||||
|
||||
t.Run("sums nested directories bottom up", func(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
outer := filepath.Join(root, "outer")
|
||||
writeDirNode(t, outer, 0)
|
||||
inner := filepath.Join(root, "inner")
|
||||
writeDirNode(t, inner, 0)
|
||||
f1 := filepath.Join(root, "f1")
|
||||
writeFileNode(t, f1, 10)
|
||||
f2 := filepath.Join(root, "f2")
|
||||
writeFileNode(t, f2, 32)
|
||||
|
||||
linkChild(t, inner, f2, "f2")
|
||||
linkChild(t, outer, f1, "f1")
|
||||
linkChild(t, outer, inner, "inner")
|
||||
|
||||
size, corrected, err := recalculateNode(nil, "spaceid", outer, false, false, tablewriter.NewTable(os.Stdout))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, uint64(42), size)
|
||||
require.Equal(t, 2, corrected, "both the inner and the outer directory are corrected")
|
||||
require.Equal(t, "32", storedTreesize(t, inner))
|
||||
require.Equal(t, "42", storedTreesize(t, outer))
|
||||
})
|
||||
|
||||
t.Run("treats a node without a type attribute as a directory", func(t *testing.T) {
|
||||
// space roots carry no type attribute
|
||||
root := t.TempDir()
|
||||
spaceRoot := filepath.Join(root, "space")
|
||||
require.NoError(t, os.MkdirAll(spaceRoot, 0700))
|
||||
writeNode(t, spaceRoot, map[string][]byte{
|
||||
prefixes.TreesizeAttr: []byte("999"),
|
||||
})
|
||||
f := filepath.Join(root, "file")
|
||||
writeFileNode(t, f, 64)
|
||||
linkChild(t, spaceRoot, f, "file")
|
||||
|
||||
size, corrected, err := recalculateNode(nil, "spaceid", spaceRoot, false, false, tablewriter.NewTable(os.Stdout))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, uint64(64), size)
|
||||
require.Equal(t, 1, corrected)
|
||||
require.Equal(t, "64", storedTreesize(t, spaceRoot))
|
||||
})
|
||||
|
||||
t.Run("skips dangling child links", func(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
dir := filepath.Join(root, "dir")
|
||||
writeDirNode(t, dir, 0)
|
||||
f := filepath.Join(root, "file")
|
||||
writeFileNode(t, f, 20)
|
||||
linkChild(t, dir, f, "file")
|
||||
require.NoError(t, os.Symlink("../gone", filepath.Join(dir, "gone")))
|
||||
|
||||
size, _, err := recalculateNode(nil, "spaceid", dir, false, false, tablewriter.NewTable(os.Stdout))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, uint64(20), size, "the dangling entry contributes nothing")
|
||||
})
|
||||
|
||||
t.Run("sets an unset treesize", func(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
dir := filepath.Join(root, "dir")
|
||||
require.NoError(t, os.MkdirAll(dir, 0700))
|
||||
writeNode(t, dir, map[string][]byte{
|
||||
prefixes.TypeAttr: []byte(strconv.FormatUint(uint64(provider.ResourceType_RESOURCE_TYPE_CONTAINER), 10)),
|
||||
})
|
||||
f := filepath.Join(root, "file")
|
||||
writeFileNode(t, f, 7)
|
||||
linkChild(t, dir, f, "file")
|
||||
|
||||
_, corrected, err := recalculateNode(nil, "spaceid", dir, false, false, tablewriter.NewTable(os.Stdout))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, corrected)
|
||||
require.Equal(t, "7", storedTreesize(t, dir))
|
||||
})
|
||||
}
|
||||
+57
-5
@@ -253,7 +253,7 @@ func (d *driver) CreateDir(ctx context.Context, ref *provider.Reference) (*stora
|
||||
}
|
||||
|
||||
func (d *driver) Delete(ctx context.Context, ref *provider.Reference) (*storage.DeleteResult, error) {
|
||||
client, _, rel, err := d.webdavClient(ctx, nil, ref)
|
||||
client, _, rel, err := d.serviceWebdavClient(ctx, ref)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -264,14 +264,24 @@ func (d *driver) Delete(ctx context.Context, ref *provider.Reference) (*storage.
|
||||
}
|
||||
|
||||
func (d *driver) TouchFile(ctx context.Context, ref *provider.Reference, markprocessing bool, mtime string) (*storage.TouchFileResult, error) {
|
||||
client, _, rel, err := d.webdavClient(ctx, nil, ref)
|
||||
client, _, rel, err := d.serviceWebdavClient(ctx, ref)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := client.Write(rel, []byte{}, 0); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &storage.TouchFileResult{}, nil
|
||||
// callers address the touched file by the ids returned here, so encode them the
|
||||
// same way a stat does (convertStatToResourceInfo)
|
||||
shareID, _ := shareInfoFromReference(ref)
|
||||
return &storage.TouchFileResult{
|
||||
SpaceID: shareID.GetOpaqueId(),
|
||||
ResourceID: &provider.ResourceId{
|
||||
StorageId: utils.OCMStorageProviderID,
|
||||
SpaceId: shareID.GetOpaqueId(),
|
||||
OpaqueId: base64.StdEncoding.EncodeToString([]byte(filepath.Join("/", rel))),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (d *driver) Move(ctx context.Context, oldRef, newRef *provider.Reference) (*storage.MoveResult, error) {
|
||||
@@ -347,6 +357,36 @@ func convertStatToResourceInfo(ref *provider.Reference, f fs.FileInfo, share *oc
|
||||
return &ri, nil
|
||||
}
|
||||
|
||||
// extractLock returns the active lock, or nil if there is none. Props.GetString
|
||||
// renders a missing key as "<nil>", so require a parseable activelock with a token.
|
||||
func extractLock(props gowebdav.Props) *provider.Lock {
|
||||
raw := props.GetString(xml.Name{Space: "DAV:", Local: "lockdiscovery"})
|
||||
|
||||
// local names only: raw is innerxml, so the d: prefix is unbound and
|
||||
// namespaced tags ("DAV: lockscope") would match nothing.
|
||||
var al struct {
|
||||
LockScope struct {
|
||||
Exclusive *struct{} `xml:"exclusive"`
|
||||
Shared *struct{} `xml:"shared"`
|
||||
} `xml:"lockscope"`
|
||||
LockToken struct {
|
||||
Href string `xml:"href"`
|
||||
} `xml:"locktoken"`
|
||||
}
|
||||
if err := xml.Unmarshal([]byte(raw), &al); err != nil {
|
||||
return nil
|
||||
}
|
||||
if al.LockToken.Href == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
lockType := provider.LockType_LOCK_TYPE_EXCL
|
||||
if al.LockScope.Shared != nil && al.LockScope.Exclusive == nil {
|
||||
lockType = provider.LockType_LOCK_TYPE_SHARED
|
||||
}
|
||||
return &provider.Lock{LockId: al.LockToken.Href, Type: lockType}
|
||||
}
|
||||
|
||||
func extractChecksum(props gowebdav.Props) *provider.ResourceChecksum {
|
||||
checksums := props.GetString(xml.Name{Space: "http://owncloud.org/ns", Local: "checksums"})
|
||||
if checksums == "" {
|
||||
@@ -534,12 +574,24 @@ func (d *driver) GetLock(ctx context.Context, ref *provider.Reference) (*provide
|
||||
return nil, err
|
||||
}
|
||||
|
||||
token, err := client.GetLock(rel)
|
||||
// gowebdav's GetLock stats with a fixed property set that omits lockdiscovery.
|
||||
// getetag keeps the 200 propstat non-empty — unlocked resources report
|
||||
// lockdiscovery in a 404 propstat, which gowebdav discards.
|
||||
info, err := client.StatWithProps(rel, []string{"lockdiscovery", "getetag"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &provider.Lock{LockId: token, Type: provider.LockType_LOCK_TYPE_EXCL}, nil
|
||||
props, ok := info.Sys().(gowebdav.Props)
|
||||
if !ok {
|
||||
return nil, errtypes.InternalError("ocm: unexpected stat result for " + ref.GetPath())
|
||||
}
|
||||
|
||||
lock := extractLock(props)
|
||||
if lock == nil {
|
||||
return nil, errtypes.NotFound("no lock found")
|
||||
}
|
||||
return lock, nil
|
||||
}
|
||||
|
||||
func (d *driver) RefreshLock(ctx context.Context, ref *provider.Reference, lock *provider.Lock, existingLockID string) error {
|
||||
|
||||
+44
-3
@@ -35,9 +35,11 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/studio-b12/gowebdav"
|
||||
tusd "github.com/tus/tusd/v2/pkg/handler"
|
||||
|
||||
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
ocmpb "github.com/cs3org/go-cs3apis/cs3/sharing/ocm/v1beta1"
|
||||
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
"github.com/owncloud/reva/v2/pkg/appctx"
|
||||
ctxpkg "github.com/owncloud/reva/v2/pkg/ctx"
|
||||
@@ -76,12 +78,51 @@ func (d *driver) InitiateUpload(ctx context.Context, ref *provider.Reference, up
|
||||
}, nil
|
||||
}
|
||||
|
||||
// MarkProcessing is a no-op: the file lives on the remote instance, so there is no
|
||||
// local node to flag while postprocessing runs.
|
||||
func (d *driver) MarkProcessing(ctx context.Context, ref *provider.Reference, processing bool, sessionID string) error {
|
||||
return errtypes.NotSupported("op not supported")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *driver) CommitUpload(_ context.Context, _ *provider.Reference, _ string, _ storage.UploadSource) error {
|
||||
return errtypes.NotSupported("op not supported")
|
||||
// CommitUpload streams the staged bytes to the remote instance.
|
||||
func (d *driver) CommitUpload(ctx context.Context, ref *provider.Reference, sessionID string, source storage.UploadSource) error {
|
||||
client, _, rel, err := d.serviceWebdavClient(ctx, ref)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client.SetInterceptor(func(method string, rq *http.Request) {
|
||||
// Set the content length on the request struct directly instead of the header.
|
||||
// The content-length header gets reset by the golang http library before
|
||||
// sending out the request, resulting in chunked encoding to be used which
|
||||
// breaks the quota checks in ocdav.
|
||||
if method == "PUT" {
|
||||
rq.ContentLength = source.Length
|
||||
}
|
||||
})
|
||||
|
||||
// the coordinator owns source.Body and closes it after this returns
|
||||
lockToken, _ := ctxpkg.ContextGetLockID(ctx)
|
||||
return client.WriteStream(rel, source.Body, 0, lockToken)
|
||||
}
|
||||
|
||||
// serviceWebdavClient builds a webdav client without needing a request auth token:
|
||||
// it authenticates as the service account and looks up the share on behalf of the
|
||||
// upload's executant.
|
||||
func (d *driver) serviceWebdavClient(ctx context.Context, ref *provider.Reference) (*gowebdav.Client, *ocmpb.ReceivedShare, string, error) {
|
||||
gwc, err := d.gateway.Next()
|
||||
if err != nil {
|
||||
return nil, nil, "", err
|
||||
}
|
||||
serviceUserCtx, err := utils.GetServiceUserContext(d.c.ServiceAccountID, gwc, d.c.ServiceAccountSecret)
|
||||
if err != nil {
|
||||
return nil, nil, "", err
|
||||
}
|
||||
executant, ok := ctxpkg.ContextGetUser(ctx)
|
||||
if !ok {
|
||||
return nil, nil, "", errtypes.BadRequest("ocm: no executant in context")
|
||||
}
|
||||
return d.webdavClient(serviceUserCtx, executant.GetId(), ref)
|
||||
}
|
||||
|
||||
func (d *driver) Upload(ctx context.Context, req storage.UploadRequest, _ storage.UploadFinishedFunc) (*provider.ResourceInfo, error) {
|
||||
|
||||
+39
-12
@@ -413,6 +413,13 @@ func (fs *Decomposedfs) CommitUpload(ctx context.Context, ref *provider.Referenc
|
||||
return errors.Wrap(err, "Decomposedfs: failed to write blob")
|
||||
}
|
||||
|
||||
// on the node, not the session: the session is deleted when the upload finishes
|
||||
if !source.ScanDate.IsZero() {
|
||||
if err := n.SetScanData(ctx, source.ScanResult, source.ScanDate); err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("nodeid", n.ID).Msg("could not set scan results")
|
||||
}
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
if p, err := n.Parent(ctx); err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("nodeid", n.ID).Msg("could not read parent for etag propagation")
|
||||
@@ -491,24 +498,38 @@ func (fs *Decomposedfs) PrepareUpload(ctx context.Context, ref *provider.Referen
|
||||
}
|
||||
}
|
||||
if info.NodeExisted && oldAttrs != nil {
|
||||
// mtime goes in the same batch: we still hold the metadata lock and
|
||||
// SetMTime would deadlock trying to retake it
|
||||
if err := fs.lu.TimeManager().OverrideMtime(ctx, n, &oldAttrs, oldMtime); err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("nodeid", n.ID).Msg("could not restore node mtime during rollback")
|
||||
}
|
||||
if err := n.SetXattrsWithContext(ctx, oldAttrs, false); err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("nodeid", n.ID).Msg("could not restore node xattrs during rollback")
|
||||
}
|
||||
if err := fs.lu.TimeManager().SetMTime(ctx, n, &oldMtime); err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("nodeid", n.ID).Msg("could not restore node mtime during rollback")
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
var (
|
||||
old *node.Node
|
||||
overwrite bool
|
||||
oldBlobsize int64
|
||||
)
|
||||
if info.NodeExisted {
|
||||
old, err := node.ReadNode(ctx, fs.lu, n.SpaceID, n.ID, false, nil, false)
|
||||
old, err = node.ReadNode(ctx, fs.lu, n.SpaceID, n.ID, false, nil, false)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "PrepareUpload: failed to read existing node")
|
||||
}
|
||||
if _, err := node.CheckQuota(ctx, n.SpaceRoot, old.BlobID != "", uint64(old.Blobsize), uint64(info.Size)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
overwrite = old.BlobID != ""
|
||||
oldBlobsize = old.Blobsize
|
||||
}
|
||||
|
||||
// also for new files: the coordinator's check fails open without GetQuota
|
||||
// permission, and CheckQuota guards disk space too
|
||||
if _, err := node.CheckQuota(ctx, n.SpaceRoot, overwrite, uint64(oldBlobsize), uint64(info.Size)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if info.NodeExisted {
|
||||
oldMtime, err = old.GetMTime(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -633,7 +654,7 @@ func (fs *Decomposedfs) RollbackUpload(ctx context.Context, ref *provider.Refere
|
||||
return fmt.Errorf("RollbackUpload: node lookup failed: %w", err)
|
||||
}
|
||||
if !n.Exists {
|
||||
return nil // new node; coordinator calls Delete separately
|
||||
return nil // nothing was written yet
|
||||
}
|
||||
n.SpaceRoot, err = node.ReadNode(ctx, fs.lu, n.SpaceID, n.SpaceID, false, nil, false)
|
||||
if err != nil {
|
||||
@@ -652,13 +673,19 @@ func (fs *Decomposedfs) RollbackUpload(ctx context.Context, ref *provider.Refere
|
||||
if err := n.RevertCurrentRevision(ctx, false); err != nil {
|
||||
return err
|
||||
}
|
||||
if sizeDiff != 0 {
|
||||
if err := fs.tp.Propagate(ctx, n, -sizeDiff); err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Msg("RollbackUpload: could not revert propagate")
|
||||
}
|
||||
} else {
|
||||
// the upload created this node, so undo it. Purge, not trash: the file never
|
||||
// became visible, and Purge needs no Delete permission
|
||||
if err := n.Purge(ctx); err != nil {
|
||||
return fmt.Errorf("RollbackUpload: could not purge node: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if sizeDiff != 0 {
|
||||
if err := fs.tp.Propagate(ctx, n, -sizeDiff); err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Msg("RollbackUpload: could not revert propagate")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1323,7 +1323,7 @@ github.com/orcaman/concurrent-map
|
||||
# github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245
|
||||
## explicit; go 1.18
|
||||
github.com/owncloud/libre-graph-api-go
|
||||
# github.com/owncloud/reva/v2 v2.0.0-20260806084131-831afd01e5d4
|
||||
# github.com/owncloud/reva/v2 v2.0.0-20260807095944-8056f5e1297e
|
||||
## explicit; go 1.26
|
||||
github.com/owncloud/reva/v2/cmd/revad/internal/grace
|
||||
github.com/owncloud/reva/v2/cmd/revad/runtime
|
||||
|
||||
+2
-3
@@ -115,9 +115,8 @@
|
||||
"minimatch": "10.2.5",
|
||||
"brace-expansion": "5.0.9",
|
||||
"ws": "8.21.0",
|
||||
"js-yaml": "4.3.1",
|
||||
"fast-uri": "3.1.5",
|
||||
"nanoid": "3.3.17"
|
||||
"js-yaml": "4.3.0",
|
||||
"fast-uri": "3.1.5"
|
||||
},
|
||||
"patchedDependencies": {
|
||||
"caf@15.0.1": "patches/caf@15.0.1.patch",
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
v-if="resource"
|
||||
id="app-top-bar-resource"
|
||||
:is-thumbnail-displayed="false"
|
||||
:is-resource-clickable="false"
|
||||
:is-extension-displayed="areFileExtensionsShown"
|
||||
:path-prefix="getPathPrefix(resource)"
|
||||
:resource="resource"
|
||||
|
||||
@@ -189,7 +189,6 @@ const tooltipLabelIcon = computed(() => {
|
||||
display: inline-flex;
|
||||
justify-content: flex-start;
|
||||
overflow: visible !important;
|
||||
min-width: 0;
|
||||
|
||||
&-no-interaction {
|
||||
pointer-events: none;
|
||||
|
||||
@@ -205,7 +205,8 @@ export const useFileActions = () => {
|
||||
}) => {
|
||||
const remoteItemId = isShareSpaceResource(space) ? space.id : undefined
|
||||
const routeName = appFileExtension.routeName || appFileExtension.app
|
||||
return getEditorRouteOpts(routeName, space, resource, mode, remoteItemId)
|
||||
const routeOpts = getEditorRouteOpts(routeName, space, resource, mode, remoteItemId)
|
||||
return router.resolve(routeOpts)
|
||||
}
|
||||
const getEditorRouteOpts = (
|
||||
routeName: RouteRecordName,
|
||||
|
||||
@@ -2,36 +2,36 @@
|
||||
|
||||
exports[`AppTopBar > if a resource is present > renders a resource and dropdownActions (if given) and a close button 1`] = `
|
||||
"<portal to="app.runtime.header.left" dropdownactions="undefined">
|
||||
<div class="oc-app-top-bar oc-flex"><span class="oc-app-top-bar-inner oc-px-m oc-flex oc-flex-middle oc-flex-between"><div class="open-file-bar oc-flex"><resource-list-item-stub resource="undefined" pathprefix="[Function]" ispathdisplayed="true" parentfoldername="Personal" parentfolderlinkiconadditionalattributes="[object Object]" isextensiondisplayed="true" isthumbnaildisplayed="false" isicondisplayed="true" isresourceclickable="false" issearchresult="false" id="app-top-bar-resource"></resource-list-item-stub></div> <div class="oc-flex main-actions"><!--v-if--> <!--v-if--> <!--v-if--> <oc-button-stub type="button" disabled="false" size="medium" arialabel="Close" submit="button" variation="brand" appearance="raw-inverse" justifycontent="center" gapsize="medium" showspinner="false" id="app-top-bar-close"></oc-button-stub></div></span></div>
|
||||
<div class="oc-app-top-bar oc-flex"><span class="oc-app-top-bar-inner oc-px-m oc-flex oc-flex-middle oc-flex-between"><div class="open-file-bar oc-flex"><resource-list-item-stub resource="undefined" pathprefix="[Function]" ispathdisplayed="true" parentfoldername="Personal" parentfolderlinkiconadditionalattributes="[object Object]" isextensiondisplayed="true" isthumbnaildisplayed="false" isicondisplayed="true" isresourceclickable="true" issearchresult="false" id="app-top-bar-resource"></resource-list-item-stub></div> <div class="oc-flex main-actions"><!--v-if--> <!--v-if--> <!--v-if--> <oc-button-stub type="button" disabled="false" size="medium" arialabel="Close" submit="button" variation="brand" appearance="raw-inverse" justifycontent="center" gapsize="medium" showspinner="false" id="app-top-bar-close"></oc-button-stub></div></span></div>
|
||||
</portal>"
|
||||
`;
|
||||
|
||||
exports[`AppTopBar > if a resource is present > renders a resource and dropdownActions as well as mainActions (if both are passed) and a close button 1`] = `
|
||||
"<portal to="app.runtime.header.left" dropdownactions="undefined">
|
||||
<div class="oc-app-top-bar oc-flex"><span class="oc-app-top-bar-inner oc-px-m oc-flex oc-flex-middle oc-flex-between"><div class="open-file-bar oc-flex"><resource-list-item-stub resource="undefined" pathprefix="[Function]" ispathdisplayed="true" parentfoldername="Personal" parentfolderlinkiconadditionalattributes="[object Object]" isextensiondisplayed="true" isthumbnaildisplayed="false" isicondisplayed="true" isresourceclickable="false" issearchresult="false" id="app-top-bar-resource"></resource-list-item-stub></div> <div class="oc-flex main-actions"><!--v-if--> <!--v-if--> <context-action-menu-stub menusections="[object Object]" actionoptions="[object Object]" appearance="raw-inverse" variation="brand"></context-action-menu-stub> <oc-button-stub type="button" disabled="false" size="medium" arialabel="Close" submit="button" variation="brand" appearance="raw-inverse" justifycontent="center" gapsize="medium" showspinner="false" id="app-top-bar-close"></oc-button-stub></div></span></div>
|
||||
<div class="oc-app-top-bar oc-flex"><span class="oc-app-top-bar-inner oc-px-m oc-flex oc-flex-middle oc-flex-between"><div class="open-file-bar oc-flex"><resource-list-item-stub resource="undefined" pathprefix="[Function]" ispathdisplayed="true" parentfoldername="Personal" parentfolderlinkiconadditionalattributes="[object Object]" isextensiondisplayed="true" isthumbnaildisplayed="false" isicondisplayed="true" isresourceclickable="true" issearchresult="false" id="app-top-bar-resource"></resource-list-item-stub></div> <div class="oc-flex main-actions"><!--v-if--> <!--v-if--> <context-action-menu-stub menusections="[object Object]" actionoptions="[object Object]" appearance="raw-inverse" variation="brand"></context-action-menu-stub> <oc-button-stub type="button" disabled="false" size="medium" arialabel="Close" submit="button" variation="brand" appearance="raw-inverse" justifycontent="center" gapsize="medium" showspinner="false" id="app-top-bar-close"></oc-button-stub></div></span></div>
|
||||
</portal>"
|
||||
`;
|
||||
|
||||
exports[`AppTopBar > if a resource is present > renders a resource and mainActions (if given) and a close button 1`] = `
|
||||
"<portal to="app.runtime.header.left" dropdownactions="">
|
||||
<div class="oc-app-top-bar oc-flex"><span class="oc-app-top-bar-inner oc-px-m oc-flex oc-flex-middle oc-flex-between"><div class="open-file-bar oc-flex"><resource-list-item-stub resource="undefined" pathprefix="[Function]" ispathdisplayed="true" parentfoldername="Personal" parentfolderlinkiconadditionalattributes="[object Object]" isextensiondisplayed="true" isthumbnaildisplayed="false" isicondisplayed="true" isresourceclickable="false" issearchresult="false" id="app-top-bar-resource"></resource-list-item-stub></div> <div class="oc-flex main-actions"><!--v-if--> <!--v-if--> <context-action-menu-stub menusections="[object Object]" actionoptions="[object Object]" appearance="raw-inverse" variation="brand"></context-action-menu-stub> <oc-button-stub type="button" disabled="false" size="medium" arialabel="Close" submit="button" variation="brand" appearance="raw-inverse" justifycontent="center" gapsize="medium" showspinner="false" id="app-top-bar-close"></oc-button-stub></div></span></div>
|
||||
<div class="oc-app-top-bar oc-flex"><span class="oc-app-top-bar-inner oc-px-m oc-flex oc-flex-middle oc-flex-between"><div class="open-file-bar oc-flex"><resource-list-item-stub resource="undefined" pathprefix="[Function]" ispathdisplayed="true" parentfoldername="Personal" parentfolderlinkiconadditionalattributes="[object Object]" isextensiondisplayed="true" isthumbnaildisplayed="false" isicondisplayed="true" isresourceclickable="true" issearchresult="false" id="app-top-bar-resource"></resource-list-item-stub></div> <div class="oc-flex main-actions"><!--v-if--> <!--v-if--> <context-action-menu-stub menusections="[object Object]" actionoptions="[object Object]" appearance="raw-inverse" variation="brand"></context-action-menu-stub> <oc-button-stub type="button" disabled="false" size="medium" arialabel="Close" submit="button" variation="brand" appearance="raw-inverse" justifycontent="center" gapsize="medium" showspinner="false" id="app-top-bar-close"></oc-button-stub></div></span></div>
|
||||
</portal>"
|
||||
`;
|
||||
|
||||
exports[`AppTopBar > if a resource is present > renders a resource and no actions (if none given) and a close button 1`] = `
|
||||
"<portal to="app.runtime.header.left" dropdownactions="">
|
||||
<div class="oc-app-top-bar oc-flex"><span class="oc-app-top-bar-inner oc-px-m oc-flex oc-flex-middle oc-flex-between"><div class="open-file-bar oc-flex"><resource-list-item-stub resource="undefined" pathprefix="[Function]" ispathdisplayed="true" parentfoldername="Personal" parentfolderlinkiconadditionalattributes="[object Object]" isextensiondisplayed="true" isthumbnaildisplayed="false" isicondisplayed="true" isresourceclickable="false" issearchresult="false" id="app-top-bar-resource"></resource-list-item-stub></div> <div class="oc-flex main-actions"><!--v-if--> <!--v-if--> <!--v-if--> <oc-button-stub type="button" disabled="false" size="medium" arialabel="Close" submit="button" variation="brand" appearance="raw-inverse" justifycontent="center" gapsize="medium" showspinner="false" id="app-top-bar-close"></oc-button-stub></div></span></div>
|
||||
<div class="oc-app-top-bar oc-flex"><span class="oc-app-top-bar-inner oc-px-m oc-flex oc-flex-middle oc-flex-between"><div class="open-file-bar oc-flex"><resource-list-item-stub resource="undefined" pathprefix="[Function]" ispathdisplayed="true" parentfoldername="Personal" parentfolderlinkiconadditionalattributes="[object Object]" isextensiondisplayed="true" isthumbnaildisplayed="false" isicondisplayed="true" isresourceclickable="true" issearchresult="false" id="app-top-bar-resource"></resource-list-item-stub></div> <div class="oc-flex main-actions"><!--v-if--> <!--v-if--> <!--v-if--> <oc-button-stub type="button" disabled="false" size="medium" arialabel="Close" submit="button" variation="brand" appearance="raw-inverse" justifycontent="center" gapsize="medium" showspinner="false" id="app-top-bar-close"></oc-button-stub></div></span></div>
|
||||
</portal>"
|
||||
`;
|
||||
|
||||
exports[`AppTopBar > if a resource is present > renders a resource without file extension if areFileExtensionsShown is set to false 1`] = `
|
||||
"<portal to="app.runtime.header.left" dropdownactions="undefined">
|
||||
<div class="oc-app-top-bar oc-flex"><span class="oc-app-top-bar-inner oc-px-m oc-flex oc-flex-middle oc-flex-between"><div class="open-file-bar oc-flex"><resource-list-item-stub resource="undefined" pathprefix="[Function]" ispathdisplayed="true" parentfoldername="Personal" parentfolderlinkiconadditionalattributes="[object Object]" isextensiondisplayed="false" isthumbnaildisplayed="false" isicondisplayed="true" isresourceclickable="false" issearchresult="false" id="app-top-bar-resource"></resource-list-item-stub></div> <div class="oc-flex main-actions"><!--v-if--> <!--v-if--> <context-action-menu-stub menusections="[object Object]" actionoptions="[object Object]" appearance="raw-inverse" variation="brand"></context-action-menu-stub> <oc-button-stub type="button" disabled="false" size="medium" arialabel="Close" submit="button" variation="brand" appearance="raw-inverse" justifycontent="center" gapsize="medium" showspinner="false" id="app-top-bar-close"></oc-button-stub></div></span></div>
|
||||
<div class="oc-app-top-bar oc-flex"><span class="oc-app-top-bar-inner oc-px-m oc-flex oc-flex-middle oc-flex-between"><div class="open-file-bar oc-flex"><resource-list-item-stub resource="undefined" pathprefix="[Function]" ispathdisplayed="true" parentfoldername="Personal" parentfolderlinkiconadditionalattributes="[object Object]" isextensiondisplayed="false" isthumbnaildisplayed="false" isicondisplayed="true" isresourceclickable="true" issearchresult="false" id="app-top-bar-resource"></resource-list-item-stub></div> <div class="oc-flex main-actions"><!--v-if--> <!--v-if--> <context-action-menu-stub menusections="[object Object]" actionoptions="[object Object]" appearance="raw-inverse" variation="brand"></context-action-menu-stub> <oc-button-stub type="button" disabled="false" size="medium" arialabel="Close" submit="button" variation="brand" appearance="raw-inverse" justifycontent="center" gapsize="medium" showspinner="false" id="app-top-bar-close"></oc-button-stub></div></span></div>
|
||||
</portal>"
|
||||
`;
|
||||
|
||||
exports[`AppTopBar > if no resource is present > renders only a close button 1`] = `
|
||||
"<portal to="app.runtime.header.left" dropdownactions="">
|
||||
<div class="oc-app-top-bar oc-flex"><span class="oc-app-top-bar-inner oc-px-m oc-flex oc-flex-middle oc-flex-between"><div class="open-file-bar oc-flex"><resource-list-item-stub resource="undefined" pathprefix="[Function]" ispathdisplayed="true" parentfoldername="Personal" parentfolderlinkiconadditionalattributes="[object Object]" isextensiondisplayed="true" isthumbnaildisplayed="false" isicondisplayed="true" isresourceclickable="false" issearchresult="false" id="app-top-bar-resource"></resource-list-item-stub></div> <div class="oc-flex main-actions"><!--v-if--> <!--v-if--> <!--v-if--> <oc-button-stub type="button" disabled="false" size="medium" arialabel="Close" submit="button" variation="brand" appearance="raw-inverse" justifycontent="center" gapsize="medium" showspinner="false" id="app-top-bar-close"></oc-button-stub></div></span></div>
|
||||
<div class="oc-app-top-bar oc-flex"><span class="oc-app-top-bar-inner oc-px-m oc-flex oc-flex-middle oc-flex-between"><div class="open-file-bar oc-flex"><resource-list-item-stub resource="undefined" pathprefix="[Function]" ispathdisplayed="true" parentfoldername="Personal" parentfolderlinkiconadditionalattributes="[object Object]" isextensiondisplayed="true" isthumbnaildisplayed="false" isicondisplayed="true" isresourceclickable="true" issearchresult="false" id="app-top-bar-resource"></resource-list-item-stub></div> <div class="oc-flex main-actions"><!--v-if--> <!--v-if--> <!--v-if--> <oc-button-stub type="button" disabled="false" size="medium" arialabel="Close" submit="button" variation="brand" appearance="raw-inverse" justifycontent="center" gapsize="medium" showspinner="false" id="app-top-bar-close"></oc-button-stub></div></span></div>
|
||||
</portal>"
|
||||
`;
|
||||
@@ -3,8 +3,7 @@ import { Action, FileActionOptions, useFileActions } from '../../../../../src/co
|
||||
import {
|
||||
defaultComponentMocks,
|
||||
RouteLocation,
|
||||
getComposableWrapper,
|
||||
createRouter
|
||||
getComposableWrapper
|
||||
} from '@ownclouders/web-test-helpers'
|
||||
import { computed, unref } from 'vue'
|
||||
import { describe } from 'vitest'
|
||||
@@ -58,27 +57,6 @@ describe('fileActions', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('editor action "route"', () => {
|
||||
it.each([
|
||||
['#.txt', '/personal%2Fadmin%2F%23.txt'],
|
||||
['a?b.txt', '/personal%2Fadmin%2Fa%3Fb.txt'],
|
||||
['a#b?c.txt', '/personal%2Fadmin%2Fa%23b%3Fc.txt']
|
||||
])('percent-encodes "%s" when the router resolves the route', (fileName, expectedPath) => {
|
||||
getWrapper({
|
||||
setup: ({ editorActions }) => {
|
||||
const [textEditor] = unref(editorActions)
|
||||
const route = (textEditor as Action<FileActionOptions>).route({
|
||||
space: mock<SpaceResource>({
|
||||
getDriveAliasAndItem: () => `personal/admin/${fileName}`
|
||||
}),
|
||||
resources: [mock<Resource>({ path: `/${fileName}`, extension: 'txt' })]
|
||||
})
|
||||
|
||||
expect(createTextEditorRouter().resolve(route).path).toEqual(expectedPath)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('secure view context', () => {
|
||||
describe('computed property "editorActions"', () => {
|
||||
it('only displays editors that support secure view', () => {
|
||||
@@ -105,14 +83,6 @@ describe('fileActions', () => {
|
||||
})
|
||||
})
|
||||
|
||||
function createTextEditorRouter() {
|
||||
return createRouter({
|
||||
routes: [
|
||||
{ path: '/:driveAliasAndItem(.*)?', name: 'text-editor', component: { template: '<div />' } }
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
function getWrapper({
|
||||
setup,
|
||||
currentRoute = mock<RouteLocation>({ name: 'files-spaces-generic' })
|
||||
|
||||
Generated
+18
-12
@@ -18,9 +18,8 @@ overrides:
|
||||
minimatch: 10.2.5
|
||||
brace-expansion: 5.0.9
|
||||
ws: 8.21.0
|
||||
js-yaml: 4.3.1
|
||||
js-yaml: 4.3.0
|
||||
fast-uri: 3.1.5
|
||||
nanoid: 3.3.17
|
||||
|
||||
patchedDependencies:
|
||||
caf@15.0.1:
|
||||
@@ -5385,8 +5384,8 @@ packages:
|
||||
js-tokens@4.0.0:
|
||||
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
|
||||
|
||||
js-yaml@4.3.1:
|
||||
resolution: {integrity: sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==}
|
||||
js-yaml@4.3.0:
|
||||
resolution: {integrity: sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q==}
|
||||
hasBin: true
|
||||
|
||||
jsdom@27.4.0:
|
||||
@@ -5819,11 +5818,16 @@ packages:
|
||||
namespace-emitter@2.0.1:
|
||||
resolution: {integrity: sha512-N/sMKHniSDJBjfrkbS/tpkPj4RAbvW3mr8UAzvlMHyun93XEm83IAvhWtJVHo+RHn/oO8Job5YN4b+wRjSVp5g==}
|
||||
|
||||
nanoid@3.3.17:
|
||||
resolution: {integrity: sha512-xQLf0A3HOMlgHq0n247/LRuAOYmB7dXJ/DvAxGvsSBij45XtBSmQycu+F8ODbHwns/XyFZagyL1+J0Offw1E0g==}
|
||||
nanoid@3.3.16:
|
||||
resolution: {integrity: sha512-bzlKTyNJ7+LdGIIwy8ijFpIqEQIvafahV7eYykJ8Cvh42EdJeODoJ6gUJXpQJvej1BddH8OqTXZNE/KfbWAu8Q==}
|
||||
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
|
||||
hasBin: true
|
||||
|
||||
nanoid@5.1.16:
|
||||
resolution: {integrity: sha512-kVrnsrJqMR8+oLJnGEmSWw9BivK5mt7H3FZatVRjrc5wGqFYuBxX1yG7+A7Gi5AefkX6t/oCkizcQgpu0cY1dQ==}
|
||||
engines: {node: ^18 || >=20}
|
||||
hasBin: true
|
||||
|
||||
natural-compare@1.4.0:
|
||||
resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==}
|
||||
|
||||
@@ -8744,7 +8748,7 @@ snapshots:
|
||||
globals: 14.0.0
|
||||
ignore: 5.3.2
|
||||
import-fresh: 3.3.1
|
||||
js-yaml: 4.3.1
|
||||
js-yaml: 4.3.0
|
||||
minimatch: 10.2.5
|
||||
strip-json-comments: 3.1.1
|
||||
transitivePeerDependencies:
|
||||
@@ -9998,7 +10002,7 @@ snapshots:
|
||||
lodash: 4.18.1
|
||||
mime-match: 1.0.2
|
||||
namespace-emitter: 2.0.1
|
||||
nanoid: 3.3.17
|
||||
nanoid: 5.1.16
|
||||
preact: 10.29.7
|
||||
transitivePeerDependencies:
|
||||
- preact-render-to-string
|
||||
@@ -10935,7 +10939,7 @@ snapshots:
|
||||
dependencies:
|
||||
env-paths: 2.2.1
|
||||
import-fresh: 3.3.1
|
||||
js-yaml: 4.3.1
|
||||
js-yaml: 4.3.0
|
||||
parse-json: 5.2.0
|
||||
optionalDependencies:
|
||||
typescript: 5.9.3
|
||||
@@ -12283,7 +12287,7 @@ snapshots:
|
||||
|
||||
js-tokens@4.0.0: {}
|
||||
|
||||
js-yaml@4.3.1:
|
||||
js-yaml@4.3.0:
|
||||
dependencies:
|
||||
argparse: 2.0.1
|
||||
|
||||
@@ -12727,7 +12731,9 @@ snapshots:
|
||||
|
||||
namespace-emitter@2.0.1: {}
|
||||
|
||||
nanoid@3.3.17: {}
|
||||
nanoid@3.3.16: {}
|
||||
|
||||
nanoid@5.1.16: {}
|
||||
|
||||
natural-compare@1.4.0: {}
|
||||
|
||||
@@ -13154,7 +13160,7 @@ snapshots:
|
||||
|
||||
postcss@8.5.21:
|
||||
dependencies:
|
||||
nanoid: 3.3.17
|
||||
nanoid: 3.3.16
|
||||
picocolors: 1.1.1
|
||||
source-map-js: 1.2.1
|
||||
|
||||
|
||||
Reference in new issue
Block a user