mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#18832: Overwrite files when unzipping a media folder
Work Item: 18832 --HG-- branch : 1.x
This commit is contained in:
@@ -310,8 +310,20 @@ namespace Orchard.Media.Services {
|
||||
// skip disallowed files
|
||||
if (FileAllowed(entry.FileName, false)) {
|
||||
string fullFileName = _storageProvider.Combine(targetFolder, entry.FileName);
|
||||
|
||||
using (var stream = entry.OpenReader()) {
|
||||
_storageProvider.TrySaveStream(fullFileName, stream);
|
||||
// the call will return false if the file already exists
|
||||
if (!_storageProvider.TrySaveStream(fullFileName, stream)) {
|
||||
|
||||
// try to delete the file and save again
|
||||
try {
|
||||
_storageProvider.DeleteFile(fullFileName);
|
||||
_storageProvider.TrySaveStream(fullFileName, stream);
|
||||
}
|
||||
catch (ArgumentException) {
|
||||
// ignore the exception as the file doesn't exist
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user