Created cleanup functionality for syncthing (#6884)

* Add clean up for Simple File Versioning pt.1

created test

* Add clean up for Simple File Versioning pt.2

Passing the test

* stuck on how javascript communicates with backend

* Add trash clean up for Simple File Versioning

Add trash clean up functionality of to allow the user to delete backups
after specified amount of days.

* Fixed html and js style

* Refactored cleanup test cases

Refactored cleanup test cases to one file and deleted duplicated code.

* Added copyright to test file

* Refactor folder cleanout to utility function

* change utility function to package private

* refactored utility function; fixed build errors

* Updated copyright year.

* refactor test and logging

* refactor html and js

* revert style change in html

* reverted changes in html and some js

* checkout origin head version edit...html

* checkout upstream master and correct file
This commit is contained in:
Rahmi Pruitt
2020-08-24 12:14:30 +01:00
committed by GitHub
parent dfc3525cf7
commit 5b953033c7
8 changed files with 160 additions and 128 deletions
+7 -2
View File
@@ -22,6 +22,7 @@ func init() {
type simple struct {
keep int
cleanoutDays int
folderFs fs.Filesystem
versionsFs fs.Filesystem
copyRangeMethod fs.CopyRangeMethod
@@ -29,12 +30,16 @@ type simple struct {
func newSimple(cfg config.FolderConfiguration) Versioner {
var keep, err = strconv.Atoi(cfg.Versioning.Params["keep"])
cleanoutDays, _ := strconv.Atoi(cfg.Versioning.Params["cleanoutDays"])
// On error we default to 0, "do not clean out the trash can"
if err != nil {
keep = 5 // A reasonable default
}
s := simple{
keep: keep,
cleanoutDays: cleanoutDays,
folderFs: cfg.Filesystem(),
versionsFs: versionerFsFromFolderCfg(cfg),
copyRangeMethod: cfg.CopyRangeMethod,
@@ -75,6 +80,6 @@ func (v simple) Restore(filepath string, versionTime time.Time) error {
return restoreFile(v.copyRangeMethod, v.versionsFs, v.folderFs, filepath, versionTime, TagFilename)
}
func (v simple) Clean(_ context.Context) error {
return nil
func (v simple) Clean(ctx context.Context) error {
return cleanByDay(ctx, v.versionsFs, v.cleanoutDays)
}