mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-07 04:40:05 -06:00
Merge pull request #10432 from 2403905/issue-10430
Remove deprecated CLI commands
This commit is contained in:
8
changelog/unreleased/remove-deprecated-cli-commans.md
Normal file
8
changelog/unreleased/remove-deprecated-cli-commans.md
Normal file
@@ -0,0 +1,8 @@
|
||||
Enhancement: Remove deprecated CLI commands
|
||||
|
||||
We removed the following deprecated CLI commands:
|
||||
`ocis storage-users uploads list`
|
||||
`ocis storage-users uploads clean`
|
||||
|
||||
https://github.com/owncloud/ocis/pull/10430
|
||||
https://github.com/owncloud/ocis/issues/10428
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
tw "github.com/olekukonko/tablewriter"
|
||||
@@ -47,53 +46,7 @@ func Uploads(cfg *config.Config) *cli.Command {
|
||||
Name: "uploads",
|
||||
Usage: "manage unfinished uploads",
|
||||
Subcommands: []*cli.Command{
|
||||
ListUploads(cfg),
|
||||
ListUploadSessions(cfg),
|
||||
PurgeExpiredUploads(cfg),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// ListUploads prints a list of all incomplete uploads
|
||||
func ListUploads(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "list",
|
||||
Usage: "Print a list of all incomplete uploads (deprecated, use sessions)",
|
||||
Before: func(c *cli.Context) error {
|
||||
return configlog.ReturnFatal(parser.ParseConfig(cfg))
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
fmt.Println("Warning: This command is deprecated, use 'uploads sessions' instead")
|
||||
|
||||
f, ok := registry.NewFuncs[cfg.Driver]
|
||||
if !ok {
|
||||
fmt.Fprintf(os.Stderr, "Unknown filesystem driver '%s'\n", cfg.Driver)
|
||||
os.Exit(1)
|
||||
}
|
||||
drivers := revaconfig.StorageProviderDrivers(cfg)
|
||||
fs, err := f(drivers[cfg.Driver].(map[string]interface{}), nil)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to initialize filesystem driver '%s'\n", cfg.Driver)
|
||||
return err
|
||||
}
|
||||
|
||||
managingFS, ok := fs.(storage.UploadSessionLister)
|
||||
if !ok {
|
||||
fmt.Fprintf(os.Stderr, "'%s' storage does not support listing upload sessions\n", cfg.Driver)
|
||||
os.Exit(1)
|
||||
}
|
||||
expired := false
|
||||
uploads, err := managingFS.ListUploadSessions(c.Context, storage.UploadSessionFilter{Expired: &expired})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("Incomplete uploads:")
|
||||
for _, u := range uploads {
|
||||
ref := u.Reference()
|
||||
fmt.Printf(" - %s (Space: %s, Name: %s, Size: %d/%d, Expires: %s, Processing: %t)\n", u.ID(), ref.GetResourceId().GetSpaceId(), u.Filename(), u.Offset(), u.Size(), u.Expires(), u.IsProcessing())
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -258,63 +211,6 @@ func ListUploadSessions(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
}
|
||||
|
||||
// PurgeExpiredUploads is the entry point for the clean command
|
||||
func PurgeExpiredUploads(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "clean",
|
||||
Usage: "Clean up leftovers from expired uploads",
|
||||
Before: func(c *cli.Context) error {
|
||||
return configlog.ReturnFatal(parser.ParseConfig(cfg))
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
fmt.Println("Warning: This command is deprecated, use 'uploads sessions --clean' instead")
|
||||
f, ok := registry.NewFuncs[cfg.Driver]
|
||||
if !ok {
|
||||
fmt.Fprintf(os.Stderr, "Unknown filesystem driver '%s'\n", cfg.Driver)
|
||||
os.Exit(1)
|
||||
}
|
||||
drivers := revaconfig.StorageProviderDrivers(cfg)
|
||||
fs, err := f(drivers[cfg.Driver].(map[string]interface{}), nil)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to initialize filesystem driver '%s'\n", cfg.Driver)
|
||||
return err
|
||||
}
|
||||
|
||||
managingFS, ok := fs.(storage.UploadSessionLister)
|
||||
if !ok {
|
||||
fmt.Fprintf(os.Stderr, "'%s' storage does not support clean expired uploads\n", cfg.Driver)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
processing := false
|
||||
expired := true
|
||||
uploads, err := managingFS.ListUploadSessions(c.Context, storage.UploadSessionFilter{Expired: &expired, Processing: &processing})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("purging uploads:")
|
||||
go func() {
|
||||
for _, u := range uploads {
|
||||
ref := u.Reference()
|
||||
fmt.Printf(" - %s (Space: %s, Name: %s, Size: %d/%d, Expires: %s, Processing: %t)\n", ref.GetResourceId().GetSpaceId(), u.ID(), u.Filename(), u.Offset(), u.Size(), u.Expires(), u.IsProcessing())
|
||||
u.Purge(c.Context)
|
||||
}
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to clean expired uploads '%s'\n", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func buildFilter(c *cli.Context) storage.UploadSessionFilter {
|
||||
filter := storage.UploadSessionFilter{}
|
||||
if c.IsSet("processing") {
|
||||
|
||||
Reference in New Issue
Block a user