add backup/restore REST API

This commit is contained in:
Nicola Murino
2019-12-27 23:12:44 +01:00
parent f49c280a7f
commit ae094d3479
26 changed files with 673 additions and 29 deletions

View File

@@ -26,8 +26,16 @@ func startQuotaScan(w http.ResponseWriter, r *http.Request) {
sendAPIResponse(w, r, err, "", http.StatusNotFound)
return
}
if sftpd.AddQuotaScan(user.Username) {
if doQuotaScan(user) {
sendAPIResponse(w, r, err, "Scan started", http.StatusCreated)
} else {
sendAPIResponse(w, r, err, "Another scan is already in progress", http.StatusConflict)
}
}
func doQuotaScan(user dataprovider.User) bool {
result := sftpd.AddQuotaScan(user.Username)
if result {
go func() {
numFiles, size, _, err := utils.ScanDirContents(user.HomeDir)
if err != nil {
@@ -38,7 +46,6 @@ func startQuotaScan(w http.ResponseWriter, r *http.Request) {
}
sftpd.RemoveQuotaScan(user.Username)
}()
} else {
sendAPIResponse(w, r, err, "Another scan is already in progress", http.StatusConflict)
}
return result
}