mirror of
https://github.com/minio/minio.git
synced 2025-01-12 15:33:22 -05:00
Avoid creating tmp directories under .minio/tmp/ to facilitate cleaning (#2187)
This commit is contained in:
parent
ac6ff67546
commit
0fddf3fe17
@ -112,12 +112,12 @@ func writeFSFormatData(storage StorageAPI, fsFormat formatConfigV1) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// writeFSMetadata - writes `fs.json` metadata.
|
// writeFSMetadata - writes `fs.json` metadata.
|
||||||
func (fs fsObjects) writeFSMetadata(bucket, prefix string, fsMeta fsMetaV1) error {
|
func (fs fsObjects) writeTempFSMetadata(bucket, path string, fsMeta fsMetaV1) error {
|
||||||
metadataBytes, err := json.Marshal(fsMeta)
|
metadataBytes, err := json.Marshal(fsMeta)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err = fs.storage.AppendFile(bucket, path.Join(prefix, fsMetaJSONFile), metadataBytes); err != nil {
|
if err = fs.storage.AppendFile(bucket, path, metadataBytes); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -229,14 +229,14 @@ func (fs fsObjects) newMultipartUpload(bucket string, object string, meta map[st
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
uploadIDPath := path.Join(mpartMetaPrefix, bucket, object, uploadID)
|
uploadIDPath := path.Join(mpartMetaPrefix, bucket, object, uploadID)
|
||||||
tempUploadIDPath := path.Join(tmpMetaPrefix, uploadID)
|
tempFSMetadataPath := path.Join(tmpMetaPrefix, getUUID()+"-"+fsMetaJSONFile)
|
||||||
if err = fs.writeFSMetadata(minioMetaBucket, tempUploadIDPath, fsMeta); err != nil {
|
if err = fs.writeTempFSMetadata(minioMetaBucket, tempFSMetadataPath, fsMeta); err != nil {
|
||||||
return "", toObjectErr(err, minioMetaBucket, tempUploadIDPath)
|
return "", toObjectErr(err, minioMetaBucket, tempFSMetadataPath)
|
||||||
}
|
}
|
||||||
err = fs.storage.RenameFile(minioMetaBucket, path.Join(tempUploadIDPath, fsMetaJSONFile), minioMetaBucket, path.Join(uploadIDPath, fsMetaJSONFile))
|
err = fs.storage.RenameFile(minioMetaBucket, tempFSMetadataPath, minioMetaBucket, path.Join(uploadIDPath, fsMetaJSONFile))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if dErr := fs.storage.DeleteFile(minioMetaBucket, path.Join(tempUploadIDPath, fsMetaJSONFile)); dErr != nil {
|
if dErr := fs.storage.DeleteFile(minioMetaBucket, tempFSMetadataPath); dErr != nil {
|
||||||
return "", toObjectErr(dErr, minioMetaBucket, tempUploadIDPath)
|
return "", toObjectErr(dErr, minioMetaBucket, tempFSMetadataPath)
|
||||||
}
|
}
|
||||||
return "", toObjectErr(err, minioMetaBucket, uploadIDPath)
|
return "", toObjectErr(err, minioMetaBucket, uploadIDPath)
|
||||||
}
|
}
|
||||||
@ -298,7 +298,7 @@ func (fs fsObjects) PutObjectPart(bucket, object, uploadID string, partID int, s
|
|||||||
defer nsMutex.Unlock(minioMetaBucket, pathJoin(mpartMetaPrefix, bucket, object, uploadID, strconv.Itoa(partID)))
|
defer nsMutex.Unlock(minioMetaBucket, pathJoin(mpartMetaPrefix, bucket, object, uploadID, strconv.Itoa(partID)))
|
||||||
|
|
||||||
partSuffix := fmt.Sprintf("object%d", partID)
|
partSuffix := fmt.Sprintf("object%d", partID)
|
||||||
tmpPartPath := path.Join(tmpMetaPrefix, uploadID, partSuffix)
|
tmpPartPath := path.Join(tmpMetaPrefix, uploadID+"-"+partSuffix)
|
||||||
|
|
||||||
// Initialize md5 writer.
|
// Initialize md5 writer.
|
||||||
md5Writer := md5.New()
|
md5Writer := md5.New()
|
||||||
@ -385,14 +385,14 @@ func (fs fsObjects) PutObjectPart(bucket, object, uploadID string, partID int, s
|
|||||||
return "", toObjectErr(err, minioMetaBucket, partPath)
|
return "", toObjectErr(err, minioMetaBucket, partPath)
|
||||||
}
|
}
|
||||||
uploadIDPath = path.Join(mpartMetaPrefix, bucket, object, uploadID)
|
uploadIDPath = path.Join(mpartMetaPrefix, bucket, object, uploadID)
|
||||||
tempUploadIDPath := path.Join(tmpMetaPrefix, uploadID)
|
tempFSMetadataPath := path.Join(tmpMetaPrefix, getUUID()+"-"+fsMetaJSONFile)
|
||||||
if err = fs.writeFSMetadata(minioMetaBucket, tempUploadIDPath, fsMeta); err != nil {
|
if err = fs.writeTempFSMetadata(minioMetaBucket, tempFSMetadataPath, fsMeta); err != nil {
|
||||||
return "", toObjectErr(err, minioMetaBucket, tempUploadIDPath)
|
return "", toObjectErr(err, minioMetaBucket, tempFSMetadataPath)
|
||||||
}
|
}
|
||||||
err = fs.storage.RenameFile(minioMetaBucket, path.Join(tempUploadIDPath, fsMetaJSONFile), minioMetaBucket, path.Join(uploadIDPath, fsMetaJSONFile))
|
err = fs.storage.RenameFile(minioMetaBucket, tempFSMetadataPath, minioMetaBucket, path.Join(uploadIDPath, fsMetaJSONFile))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if dErr := fs.storage.DeleteFile(minioMetaBucket, path.Join(tempUploadIDPath, fsMetaJSONFile)); dErr != nil {
|
if dErr := fs.storage.DeleteFile(minioMetaBucket, tempFSMetadataPath); dErr != nil {
|
||||||
return "", toObjectErr(dErr, minioMetaBucket, tempUploadIDPath)
|
return "", toObjectErr(dErr, minioMetaBucket, tempFSMetadataPath)
|
||||||
}
|
}
|
||||||
return "", toObjectErr(err, minioMetaBucket, uploadIDPath)
|
return "", toObjectErr(err, minioMetaBucket, uploadIDPath)
|
||||||
}
|
}
|
||||||
@ -525,7 +525,7 @@ func (fs fsObjects) CompleteMultipartUpload(bucket string, object string, upload
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
tempObj := path.Join(tmpMetaPrefix, uploadID, "part.1")
|
tempObj := path.Join(tmpMetaPrefix, uploadID+"-"+"part.1")
|
||||||
|
|
||||||
// Allocate staging buffer.
|
// Allocate staging buffer.
|
||||||
var buf = make([]byte, readSizeV1)
|
var buf = make([]byte, readSizeV1)
|
||||||
|
@ -364,7 +364,7 @@ func (xl xlObjects) PutObjectPart(bucket, object, uploadID string, partID int, s
|
|||||||
// accommodate concurrent PutObjectPart requests
|
// accommodate concurrent PutObjectPart requests
|
||||||
partSuffix := fmt.Sprintf("part.%d", partID)
|
partSuffix := fmt.Sprintf("part.%d", partID)
|
||||||
tmpSuffix := getUUID()
|
tmpSuffix := getUUID()
|
||||||
tmpPartPath := path.Join(tmpMetaPrefix, uploadID, tmpSuffix)
|
tmpPartPath := path.Join(tmpMetaPrefix, tmpSuffix)
|
||||||
|
|
||||||
// Initialize md5 writer.
|
// Initialize md5 writer.
|
||||||
md5Writer := md5.New()
|
md5Writer := md5.New()
|
||||||
|
Loading…
Reference in New Issue
Block a user