--HG--
branch : 1.x
This commit is contained in:
Dave Reed
2011-04-07 10:16:34 -07:00
6 changed files with 20 additions and 25 deletions

View File

@@ -233,16 +233,8 @@ namespace Orchard.Media.Controllers {
}
}
public ActionResult EditMedia(string name, DateTime lastUpdated, long size, string folderName, string mediaPath) {
var model = new MediaItemEditViewModel();
model.Name = name;
// todo: reimplement
//model.Caption = caption ?? String.Empty;
model.LastUpdated = lastUpdated;
model.Size = size;
model.FolderName = folderName;
model.MediaPath = mediaPath;
model.PublicUrl = _mediaService.GetPublicUrl(Path.Combine(mediaPath, name));
public ActionResult EditMedia(MediaItemEditViewModel model) {
model.PublicUrl = _mediaService.GetPublicUrl(Path.Combine(model.MediaPath, model.Name));
return View(model);
}
@@ -293,9 +285,8 @@ namespace Orchard.Media.Controllers {
mediaPath = viewModel.MediaPath });
}
catch (Exception exception) {
this.Error(exception, T("Editing media file failed: {0}", exception.Message), Logger, Services.Notifier);
return View(viewModel);
this.Error(exception, T("Editing media file failed."), Logger, Services.Notifier);
return EditMedia(viewModel);
}
}
}

View File

@@ -140,7 +140,10 @@ namespace Orchard.Media.Services {
Argument.ThrowIfNullOrEmpty(newFileName, "newFileName");
if (!FileAllowed(newFileName, false)) {
throw new ArgumentException(T("New file name {0} is not allowed", newFileName).ToString());
if (string.IsNullOrEmpty(Path.GetExtension(newFileName))) {
throw new ArgumentException(T("New file name \"{0}\" is not allowed. Please provide a file extension.", newFileName).ToString());
}
throw new ArgumentException(T("New file name \"{0}\" is not allowed.", newFileName).ToString());
}
_storageProvider.RenameFile(_storageProvider.Combine(folderPath, currentFileName), _storageProvider.Combine(folderPath, newFileName));