Merge pull request #4403 from wkloucek/storage-users-uploads-category
restructure storage-users upload command
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
Change: rename "uploads purge" command to "uploads clean"
|
||||||
|
|
||||||
|
We've renamed the storage-users service's "uploads purge" command
|
||||||
|
to "upload clean".
|
||||||
|
|
||||||
|
https://github.com/owncloud/ocis/pull/4403
|
||||||
@@ -19,8 +19,9 @@ import (
|
|||||||
|
|
||||||
func Uploads(cfg *config.Config) *cli.Command {
|
func Uploads(cfg *config.Config) *cli.Command {
|
||||||
return &cli.Command{
|
return &cli.Command{
|
||||||
Name: "uploads",
|
Name: "uploads",
|
||||||
Usage: "manage uploads",
|
Usage: "manage unfinished uploads",
|
||||||
|
Category: "maintenance",
|
||||||
Before: func(c *cli.Context) error {
|
Before: func(c *cli.Context) error {
|
||||||
if err := parser.ParseConfig(cfg); err != nil {
|
if err := parser.ParseConfig(cfg); err != nil {
|
||||||
fmt.Printf("%v", err)
|
fmt.Printf("%v", err)
|
||||||
@@ -38,9 +39,8 @@ func Uploads(cfg *config.Config) *cli.Command {
|
|||||||
// ListUploads prints a list of all incomplete uploads
|
// ListUploads prints a list of all incomplete uploads
|
||||||
func ListUploads(cfg *config.Config) *cli.Command {
|
func ListUploads(cfg *config.Config) *cli.Command {
|
||||||
return &cli.Command{
|
return &cli.Command{
|
||||||
Name: "list",
|
Name: "list",
|
||||||
Usage: fmt.Sprintf("Print a list of all incomplete uploads"),
|
Usage: "Print a list of all incomplete uploads",
|
||||||
Category: "services",
|
|
||||||
Before: func(c *cli.Context) error {
|
Before: func(c *cli.Context) error {
|
||||||
err := parser.ParseConfig(cfg)
|
err := parser.ParseConfig(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -85,9 +85,8 @@ func ListUploads(cfg *config.Config) *cli.Command {
|
|||||||
// PurgeExpiredUploads is the entry point for the server command.
|
// PurgeExpiredUploads is the entry point for the server command.
|
||||||
func PurgeExpiredUploads(cfg *config.Config) *cli.Command {
|
func PurgeExpiredUploads(cfg *config.Config) *cli.Command {
|
||||||
return &cli.Command{
|
return &cli.Command{
|
||||||
Name: "purge",
|
Name: "clean",
|
||||||
Usage: fmt.Sprintf("Let %s extension clean up leftovers from expired downloads", cfg.Service.Name),
|
Usage: "Clean up leftovers from expired uploads",
|
||||||
Category: "services",
|
|
||||||
Before: func(c *cli.Context) error {
|
Before: func(c *cli.Context) error {
|
||||||
err := parser.ParseConfig(cfg)
|
err := parser.ParseConfig(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -111,7 +110,7 @@ func PurgeExpiredUploads(cfg *config.Config) *cli.Command {
|
|||||||
|
|
||||||
managingFS, ok := fs.(storage.UploadsManager)
|
managingFS, ok := fs.(storage.UploadsManager)
|
||||||
if !ok {
|
if !ok {
|
||||||
fmt.Fprintf(os.Stderr, "'%s' storage does not support purging expired uploads\n", cfg.Driver)
|
fmt.Fprintf(os.Stderr, "'%s' storage does not support clean expired uploads\n", cfg.Driver)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,11 +118,10 @@ func PurgeExpiredUploads(cfg *config.Config) *cli.Command {
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
purgedChannel := make(chan tusd.FileInfo)
|
purgedChannel := make(chan tusd.FileInfo)
|
||||||
|
|
||||||
|
fmt.Println("Cleaned uploads:")
|
||||||
go func() {
|
go func() {
|
||||||
for purged := range purgedChannel {
|
for purged := range purgedChannel {
|
||||||
fmt.Printf("Purging %s (Filename: %s, Size: %d, Expires: %s)\n",
|
fmt.Printf(" - %s (%s, Size: %d, Expires: %s)\n", purged.ID, purged.MetaData["filename"], purged.Size, expiredString(purged.MetaData["expires"]))
|
||||||
purged.ID, purged.MetaData["filename"], purged.Size, expiredString(purged.MetaData["expires"]))
|
|
||||||
|
|
||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
@@ -132,7 +130,7 @@ func PurgeExpiredUploads(cfg *config.Config) *cli.Command {
|
|||||||
close(purgedChannel)
|
close(purgedChannel)
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Failed to purge expired uploads '%s'\n", err)
|
fmt.Fprintf(os.Stderr, "Failed to clean expired uploads '%s'\n", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user