Implement offline shearing/removal

This commit is contained in:
2024-03-05 12:29:10 -05:00
parent 8704ba6972
commit 85067fef40
3 changed files with 20 additions and 2 deletions
+2 -1
View File
@@ -33,7 +33,8 @@ func main() {
switch args[2] {
case "show", "-s":
cli.EntryReaderShortcut(targetLocation, false)
case "shear": // TODO offline.Shear(targetLocation), exit after run
case "shear":
offline.Shear(targetLocation)
case "gen": // TODO offline.Gen(targetLocation), exit after run
case "copy":
cli.HelpCopy()
+1 -1
View File
@@ -9,7 +9,6 @@ func AddFolder(targetLocation string) {
// create the directory specified by targetLocation
err := os.Mkdir(targetLocation, 0700)
if err != nil {
// if the directory already exists, print an error message and exit
if os.IsExist(err) {
fmt.Println(AnsiError + "Directory already exists" + AnsiReset)
os.Exit(1)
@@ -19,4 +18,5 @@ func AddFolder(targetLocation string) {
}
}
// TODO If in online mode, create the directory on the server
os.Exit(0)
}
+17
View File
@@ -0,0 +1,17 @@
package offline
import (
"fmt"
"os"
)
func Shear(targetLocation string) {
// TODO If in online mode, remove from server and add to shear list
TargetIsFile(targetLocation, true, 0) // needed because os.RemoveAll does not return an error if target does not exist
err := os.RemoveAll(targetLocation)
if err != nil {
fmt.Println(AnsiError + "Failed to remove target: " + err.Error() + AnsiReset)
os.Exit(1)
}
os.Exit(0)
}