Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: add root folder alert #21

Merged
merged 14 commits into from
Aug 7, 2024
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import (

func main() {
defer utils.TimeCost()()
if config.Folder == "/" {
fmt.Println("You should not upload the root directory, use ./ instead. 通常来说, 你不应该上传根目录, 也许你是要配置 ./")
os.Exit(1)
}

if !config.SkipSetting {
operation.SetStaticWebsiteConfig()
Expand Down
8 changes: 7 additions & 1 deletion operation/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package operation

import (
"fmt"
"os"
"path"
"strings"
"sync"
Expand All @@ -20,7 +21,12 @@ type UploadedObject struct {

// UploadObjects upload files to OSS
func UploadObjects(root string, bucket *oss.Bucket, records <-chan utils.FileInfoType, i *IncrementalConfig) ([]UploadedObject, []error) {
root = path.Clean(root) + "/"
if root == "/" {
fmt.Println("You should not upload the root directory, use ./ instead. 通常来说, 你不应该上传根目录, 也许你是要配置 ./")
os.Exit(1)
} else {
root = path.Clean(root) + "/"
}

var sw sync.WaitGroup
var errorMutex sync.Mutex
Expand Down
Loading