466005 Use Files.move(src,trgt) instead of File.rename for Part.write(filename)
This commit is contained in:
parent
4560c5d9e6
commit
9c410f8ad9
|
@ -30,6 +30,9 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -271,12 +274,11 @@ public class MultiPartInputStreamParser
|
||||||
{
|
{
|
||||||
//the part data is already written to a temporary file, just rename it
|
//the part data is already written to a temporary file, just rename it
|
||||||
_temporary = false;
|
_temporary = false;
|
||||||
|
|
||||||
File f = new File(_tmpDir, fileName);
|
Path src = _file.toPath();
|
||||||
if (_file.renameTo(f))
|
Path target = src.resolveSibling(fileName);
|
||||||
_file = f;
|
Files.move(src, target, StandardCopyOption.REPLACE_EXISTING);
|
||||||
else
|
_file = target.toFile();
|
||||||
throw new IOException("Part rename failure: from "+_file.getName()+" to "+fileName + " in "+_tmpDir.getAbsolutePath());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue