From c84e3dac381487c1f2b08ddadc008f21787e46b4 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 21 Mar 2017 18:37:46 +1100 Subject: [PATCH] Adds notes, return false if the file is not actually deleted, adds test assertions --- src/Umbraco.Core/Models/File.cs | 5 ++++- src/Umbraco.Core/Services/FileService.cs | 2 +- .../Persistence/Repositories/ScriptRepositoryTest.cs | 8 ++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Core/Models/File.cs b/src/Umbraco.Core/Models/File.cs index e271774b8d..41838a3841 100644 --- a/src/Umbraco.Core/Models/File.cs +++ b/src/Umbraco.Core/Models/File.cs @@ -49,7 +49,10 @@ namespace Umbraco.Core.Models return path .Replace('\\', System.IO.Path.DirectorySeparatorChar) .Replace('/', System.IO.Path.DirectorySeparatorChar); - //.TrimStart(System.IO.Path.DirectorySeparatorChar); + + //Don't strip the start - this was a bug fixed in 7.3, see ScriptRepositoryTests.PathTests + //.TrimStart(System.IO.Path.DirectorySeparatorChar) + //.TrimStart('/'); } /// diff --git a/src/Umbraco.Core/Services/FileService.cs b/src/Umbraco.Core/Services/FileService.cs index 6af683fa06..28fb07fe9e 100644 --- a/src/Umbraco.Core/Services/FileService.cs +++ b/src/Umbraco.Core/Services/FileService.cs @@ -868,7 +868,7 @@ namespace Umbraco.Core.Services if (partialView == null) { uow.Commit(); - return true; + return false; } if (uow.Events.DispatchCancelable(DeletingPartialView, this, new DeleteEventArgs(partialView))) diff --git a/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs index f0dc38562e..7e5dce258b 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs @@ -237,6 +237,14 @@ namespace Umbraco.Tests.Persistence.Repositories Assert.AreEqual("test-path-1.js", script.Path); Assert.AreEqual("/scripts/test-path-1.js", script.VirtualPath); + //ensure you can prefix the same path as the root path name + script = new Script("scripts/path-2/test-path-2.js") { Content = "// script" }; + repository.AddOrUpdate(script); + unitOfWork.Commit(); + Assert.IsTrue(_fileSystem.FileExists("scripts/path-2/test-path-2.js")); + Assert.AreEqual("scripts\\path-2\\test-path-2.js", script.Path); + Assert.AreEqual("/scripts/scripts/path-2/test-path-2.js", script.VirtualPath); + script = new Script("path-2/test-path-2.js") { Content = "// script" }; repository.AddOrUpdate(script); unitOfWork.Commit();