From e7f280d93b3f8566b871254bd5125a0c1abf5e24 Mon Sep 17 00:00:00 2001 From: Eirik Tsarpalis Date: Sun, 13 Mar 2016 02:24:29 +0200 Subject: [PATCH] fix #163 --- src/MBrace.Runtime/Store/FileSystemStore.fs | 8 +++++--- .../StoreTests/CloudFileStoreTests.fs | 10 ++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/MBrace.Runtime/Store/FileSystemStore.fs b/src/MBrace.Runtime/Store/FileSystemStore.fs index 78e20954..6eeb2fdb 100644 --- a/src/MBrace.Runtime/Store/FileSystemStore.fs +++ b/src/MBrace.Runtime/Store/FileSystemStore.fs @@ -18,7 +18,7 @@ type FileSystemStore private (rootPath : string, defaultDirectory : string) = [] let rootPath = rootPath - let normalize (path : string) = + let normalize defaultDirectory (path : string) = if Path.IsPathRooted path then let nf = Path.GetFullPath path if nf.StartsWith rootPath then nf @@ -26,10 +26,12 @@ type FileSystemStore private (rootPath : string, defaultDirectory : string) = let msg = sprintf "invalid path '%O'." path raise <| new FormatException(msg) else - Path.Combine(rootPath, path) |> Path.GetFullPath + Path.Combine(defaultDirectory, path) |> Path.GetFullPath [] - let defaultDirectory = normalize defaultDirectory + let defaultDirectory = normalize rootPath defaultDirectory + + let normalize p = normalize defaultDirectory p // IOException will be signifies attempt to perform concurrent writes of file. // An exception to this rule is FileNotFoundException, which is a subtype of IOException. diff --git a/tests/MBrace.Core.Tests/StoreTests/CloudFileStoreTests.fs b/tests/MBrace.Core.Tests/StoreTests/CloudFileStoreTests.fs index 19c4cdab..1ecf8a3a 100644 --- a/tests/MBrace.Core.Tests/StoreTests/CloudFileStoreTests.fs +++ b/tests/MBrace.Core.Tests/StoreTests/CloudFileStoreTests.fs @@ -336,6 +336,16 @@ type ``CloudFileStore Tests`` (parallelismFactor : int) as self = // Section 2. FileStore via MBrace runtime // + + [] + member __.``2. MBrace : relative file paths should always give same absolute`` () = + cloud { + let path = Path.GetRandomFileName() + let! cf = CloudFile.WriteAllText(path, "text") + let! fullPath = CloudPath.GetFullPath path + cf.Path |> shouldEqual fullPath + } |> runOnCloud + [] member __.``2. MBrace : PersistedValue - simple`` () = let ref = runOnCloud <| PersistedValue.New 42