Fix a crash on windows when source is malformed
This commit is contained in:
+1
-1
@@ -54,7 +54,7 @@ EXAMPLES:
|
||||
$ mc {{.Name}} backup/... http://localhost:9000/archive/ https://s3.amazonaws.com/archive/
|
||||
|
||||
4. Copy an object from Amazon S3 object storage to local filesystem on Windows.
|
||||
$ mc {{.Name}} https://s3.amazonaws.com/jukebox/vulcan_lute.ogg C:\Users\Surak\sleep.ogg
|
||||
$ mc {{.Name}} s3:documents/2014/... Documents\backup\2014
|
||||
|
||||
`,
|
||||
}
|
||||
|
||||
@@ -9,19 +9,19 @@ type GenericFileError struct {
|
||||
type FileNotFound GenericFileError
|
||||
|
||||
func (e FileNotFound) Error() string {
|
||||
return "Requested file " + e.path + "not found"
|
||||
return "Requested file " + e.path + " not found"
|
||||
}
|
||||
|
||||
// FileISDir (EISDIR) - accessed file is a directory
|
||||
type FileISDir GenericFileError
|
||||
|
||||
func (e FileISDir) Error() string {
|
||||
return "Requested file " + e.path + "is a directory"
|
||||
return "Requested file " + e.path + " is a directory"
|
||||
}
|
||||
|
||||
// FileNotDir (ENOTDIR) - accessed file is not a directory
|
||||
type FileNotDir GenericFileError
|
||||
|
||||
func (e FileNotDir) Error() string {
|
||||
return "Requested file " + e.path + "is not a directory"
|
||||
return "Requested file " + e.path + " is not a directory"
|
||||
}
|
||||
|
||||
@@ -46,16 +46,16 @@ func New(path string) client.Client {
|
||||
/// Object operations
|
||||
// getObjectMetadata - wrapper function to get file stat
|
||||
func (f *fsClient) getObjectMetadata() (os.FileInfo, error) {
|
||||
st, err := os.Stat(f.path)
|
||||
st, err := os.Stat(filepath.Clean(f.path))
|
||||
if os.IsNotExist(err) {
|
||||
return nil, iodine.New(FileNotFound{path: f.path}, nil)
|
||||
}
|
||||
if st.IsDir() {
|
||||
return nil, iodine.New(FileISDir{path: f.path}, nil)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, iodine.New(err, nil)
|
||||
}
|
||||
if st.IsDir() {
|
||||
return nil, iodine.New(FileISDir{path: f.path}, nil)
|
||||
}
|
||||
return st, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -47,12 +47,12 @@ func (f *fsClient) getObjectMetadata() (os.FileInfo, error) {
|
||||
if os.IsNotExist(err) {
|
||||
return nil, iodine.New(FileNotFound{path: f.path}, nil)
|
||||
}
|
||||
if st.IsDir() {
|
||||
return nil, iodine.New(FileISDir{path: f.path}, nil)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, iodine.New(err, nil)
|
||||
}
|
||||
if st.IsDir() {
|
||||
return nil, iodine.New(FileISDir{path: f.path}, nil)
|
||||
}
|
||||
return st, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user