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

Do not create parent directory if it is root #2120

Merged
merged 3 commits into from Mar 23, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion common/writeThoughFile.go
Expand Up @@ -44,7 +44,12 @@ var RootShareRegex = regexp.MustCompile(`(^\/\/[^\/]*\/?$)`)

func CreateParentDirectoryIfNotExist(destinationPath string, tracker FolderCreationTracker) error {
// find the parent directory
directory := destinationPath[:strings.LastIndex(destinationPath, DeterminePathSeparator(destinationPath))]
lastIndex := strings.LastIndex(destinationPath, DeterminePathSeparator(destinationPath))
if lastIndex == -1 {
// This would be root. We dont have to create it.
return nil
}
directory := destinationPath[:lastIndex]
return CreateDirectoryIfNotExist(directory, tracker)
}

Expand Down