Fix a crash on windows when source is malformed

This commit is contained in:
Harshavardhana
2015-04-22 13:20:02 -07:00
parent 10ad6465ee
commit 7ec954a78b
4 changed files with 11 additions and 11 deletions
+1 -1
View File
@@ -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
`,
}
+3 -3
View File
@@ -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"
}
+4 -4
View File
@@ -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
}
+3 -3
View File
@@ -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
}