mirror of
https://github.com/rclone/rclone.git
synced 2025-01-10 10:33:41 +08:00
b2: add daysFromStartingToCancelingUnfinishedLargeFiles to backend lifecycle command
Some checks failed
Docker beta build / Build image job (push) Has been cancelled
Some checks failed
Docker beta build / Build image job (push) Has been cancelled
See: https://www.backblaze.com/blog/effortlessly-managing-unfinished-large-file-uploads-with-b2-cloud-storage/ See: https://www.backblaze.com/docs/cloud-storage-lifecycle-rules
This commit is contained in:
parent
6a217c7dc1
commit
a34c839514
|
@ -44,6 +44,7 @@ type Bucket struct {
|
||||||
type LifecycleRule struct {
|
type LifecycleRule struct {
|
||||||
DaysFromHidingToDeleting *int `json:"daysFromHidingToDeleting"`
|
DaysFromHidingToDeleting *int `json:"daysFromHidingToDeleting"`
|
||||||
DaysFromUploadingToHiding *int `json:"daysFromUploadingToHiding"`
|
DaysFromUploadingToHiding *int `json:"daysFromUploadingToHiding"`
|
||||||
|
DaysFromStartingToCancelingUnfinishedLargeFiles *int `json:"daysFromStartingToCancelingUnfinishedLargeFiles"`
|
||||||
FileNamePrefix string `json:"fileNamePrefix"`
|
FileNamePrefix string `json:"fileNamePrefix"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2231,6 +2231,7 @@ This will dump something like this showing the lifecycle rules.
|
||||||
{
|
{
|
||||||
"daysFromHidingToDeleting": 1,
|
"daysFromHidingToDeleting": 1,
|
||||||
"daysFromUploadingToHiding": null,
|
"daysFromUploadingToHiding": null,
|
||||||
|
"daysFromStartingToCancelingUnfinishedLargeFiles": null,
|
||||||
"fileNamePrefix": ""
|
"fileNamePrefix": ""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -2259,6 +2260,7 @@ See: https://www.backblaze.com/docs/cloud-storage-lifecycle-rules
|
||||||
Opts: map[string]string{
|
Opts: map[string]string{
|
||||||
"daysFromHidingToDeleting": "After a file has been hidden for this many days it is deleted. 0 is off.",
|
"daysFromHidingToDeleting": "After a file has been hidden for this many days it is deleted. 0 is off.",
|
||||||
"daysFromUploadingToHiding": "This many days after uploading a file is hidden",
|
"daysFromUploadingToHiding": "This many days after uploading a file is hidden",
|
||||||
|
"daysFromStartingToCancelingUnfinishedLargeFiles": "Cancels any unfinished large file versions after this many days",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2278,6 +2280,13 @@ func (f *Fs) lifecycleCommand(ctx context.Context, name string, arg []string, op
|
||||||
}
|
}
|
||||||
newRule.DaysFromUploadingToHiding = &days
|
newRule.DaysFromUploadingToHiding = &days
|
||||||
}
|
}
|
||||||
|
if daysStr := opt["daysFromStartingToCancelingUnfinishedLargeFiles"]; daysStr != "" {
|
||||||
|
days, err := strconv.Atoi(daysStr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("bad daysFromStartingToCancelingUnfinishedLargeFiles: %w", err)
|
||||||
|
}
|
||||||
|
newRule.DaysFromStartingToCancelingUnfinishedLargeFiles = &days
|
||||||
|
}
|
||||||
bucketName, _ := f.split("")
|
bucketName, _ := f.split("")
|
||||||
if bucketName == "" {
|
if bucketName == "" {
|
||||||
return nil, errors.New("bucket required")
|
return nil, errors.New("bucket required")
|
||||||
|
@ -2285,7 +2294,7 @@ func (f *Fs) lifecycleCommand(ctx context.Context, name string, arg []string, op
|
||||||
}
|
}
|
||||||
|
|
||||||
var bucket *api.Bucket
|
var bucket *api.Bucket
|
||||||
if newRule.DaysFromHidingToDeleting != nil || newRule.DaysFromUploadingToHiding != nil {
|
if newRule.DaysFromHidingToDeleting != nil || newRule.DaysFromUploadingToHiding != nil || newRule.DaysFromStartingToCancelingUnfinishedLargeFiles != nil {
|
||||||
bucketID, err := f.getBucketID(ctx, bucketName)
|
bucketID, err := f.getBucketID(ctx, bucketName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in New Issue
Block a user