mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-26 20:16:15 +08:00
Merge pull request #6677 from Skrypt/issue/#6512
Fixing multiple Media Library:clone Fixes #6512
This commit is contained in:
@@ -213,8 +213,7 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
}
|
||||
|
||||
return Json(true);
|
||||
}
|
||||
catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
Logger.Error(e, "Could not delete media items.");
|
||||
return Json(false);
|
||||
}
|
||||
@@ -232,7 +231,7 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
var newFileName = Path.GetFileNameWithoutExtension(media.FileName) + " Copy" + Path.GetExtension(media.FileName);
|
||||
var newFileName = _mediaLibraryService.GetUniqueFilename(media.FolderPath, media.FileName);
|
||||
|
||||
_mediaLibraryService.CopyFile(media.FolderPath, media.FileName, media.FolderPath, newFileName);
|
||||
|
||||
@@ -241,13 +240,14 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
var clonedTitlePart = clonedContentItem.As<TitlePart>();
|
||||
|
||||
clonedMediaPart.FileName = newFileName;
|
||||
clonedMediaPart.FolderPath = media.FolderPath;
|
||||
clonedMediaPart.MimeType = media.MimeType;
|
||||
clonedTitlePart.Title = clonedTitlePart.Title + " Copy";
|
||||
|
||||
Services.ContentManager.Create(clonedContentItem);
|
||||
Services.ContentManager.Publish(clonedContentItem);
|
||||
|
||||
return Json(true);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
Logger.Error(e, "Could not clone media item.");
|
||||
return Json(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user