Skip to content

Commit

Permalink
fix #163
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriktsarpalis committed Mar 13, 2016
1 parent e8dc952 commit e7f280d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/MBrace.Runtime/Store/FileSystemStore.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ type FileSystemStore private (rootPath : string, defaultDirectory : string) =
[<DataMember(Name = "RootPath")>]
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
else
let msg = sprintf "invalid path '%O'." path
raise <| new FormatException(msg)
else
Path.Combine(rootPath, path) |> Path.GetFullPath
Path.Combine(defaultDirectory, path) |> Path.GetFullPath

[<DataMember(Name = "DefaultDirectory")>]
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.
Expand Down
10 changes: 10 additions & 0 deletions tests/MBrace.Core.Tests/StoreTests/CloudFileStoreTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,16 @@ type ``CloudFileStore Tests`` (parallelismFactor : int) as self =
// Section 2. FileStore via MBrace runtime
//


[<Test>]
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

[<Test>]
member __.``2. MBrace : PersistedValue - simple`` () =
let ref = runOnCloud <| PersistedValue.New 42
Expand Down

0 comments on commit e7f280d

Please sign in to comment.