mirror of
https://github.com/versity/versitygw.git
synced 2026-09-30 03:35:42 +00:00
The previous logic was not allowing put-object on windows when the parent directory did not already exist, and would not always return the correct error if an ancestor in the path already existed as a file. The problem is the different behavior of the os.Stat command in Windows compared to *nix in backend/posix/posix.go in function PutObjectWithPostFunc. The os.Stat returns ENOTDIR on *nix if the parent object is a file instead of a directory. On Windows, if the parent object does not exist at all, the return code of such os.Stat is ERROR_PATH_NOT_FOUND which is mapped to ENOTDIR. However this is inappropriate in this case. As a result, the return code of the os.Stat is incorrectly interpreted as if the parent object is a file instead of the parent object does not exist. Which then leads to a failed upload. This fix validates the existing parent structure on put to make sure the correct error is returned or the put is successful. Fixes #1702
26 lines
794 B
Go
26 lines
794 B
Go
// Copyright 2026 Versity Software
|
|
// This file is licensed under the Apache License, Version 2.0
|
|
// (the "License"); you may not use this file except in compliance
|
|
// with the License. You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing,
|
|
// software distributed under the License is distributed on an
|
|
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
// KIND, either express or implied. See the License for the
|
|
// specific language governing permissions and limitations
|
|
// under the License.
|
|
|
|
//go:build !windows
|
|
|
|
package posix
|
|
|
|
import (
|
|
"github.com/versity/versitygw/s3err"
|
|
)
|
|
|
|
func handleParentDirError(_ string) error {
|
|
return s3err.GetAPIError(s3err.ErrObjectParentIsFile)
|
|
}
|