You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2017/09/25 11:52:29 UTC
[5/8] lucenenet git commit: SWEEP: Swapped GetCanonicalPath() call
into each of the locations where it was originally used in Lucene
SWEEP: Swapped GetCanonicalPath() call into each of the locations where it was originally used in Lucene
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/5d9a9a04
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/5d9a9a04
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/5d9a9a04
Branch: refs/heads/master
Commit: 5d9a9a04ceca57f38bdbf0e178b8a378eb048384
Parents: 8b7b9cb
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Mon Sep 25 00:27:28 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Mon Sep 25 00:27:28 2017 +0700
----------------------------------------------------------------------
src/Lucene.Net.Benchmark/ByTask/Feeds/DirContentSource.cs | 3 ++-
.../ByTask/Feeds/ReutersContentSource.cs | 3 ++-
.../ByTask/Feeds/TrecContentSourceTest.cs | 3 ++-
src/Lucene.Net/Store/FSDirectory.cs | 8 ++++----
src/Lucene.Net/Store/NativeFSLockFactory.cs | 9 +++++----
5 files changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5d9a9a04/src/Lucene.Net.Benchmark/ByTask/Feeds/DirContentSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Benchmark/ByTask/Feeds/DirContentSource.cs b/src/Lucene.Net.Benchmark/ByTask/Feeds/DirContentSource.cs
index c14d578..a939c1b 100644
--- a/src/Lucene.Net.Benchmark/ByTask/Feeds/DirContentSource.cs
+++ b/src/Lucene.Net.Benchmark/ByTask/Feeds/DirContentSource.cs
@@ -1,5 +1,6 @@
using Lucene.Net.Benchmarks.ByTask.Utils;
using Lucene.Net.Support;
+using Lucene.Net.Support.IO;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -198,7 +199,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Feeds
}
f = inputFiles.Current;
// System.err.println(f);
- name = f.FullName + "_" + iteration;
+ name = f.GetCanonicalPath() + "_" + iteration;
}
string line = null;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5d9a9a04/src/Lucene.Net.Benchmark/ByTask/Feeds/ReutersContentSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Benchmark/ByTask/Feeds/ReutersContentSource.cs b/src/Lucene.Net.Benchmark/ByTask/Feeds/ReutersContentSource.cs
index c61ce2f..a98c054 100644
--- a/src/Lucene.Net.Benchmark/ByTask/Feeds/ReutersContentSource.cs
+++ b/src/Lucene.Net.Benchmark/ByTask/Feeds/ReutersContentSource.cs
@@ -1,4 +1,5 @@
using Lucene.Net.Benchmarks.ByTask.Utils;
+using Lucene.Net.Support.IO;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -95,7 +96,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Feeds
iteration++;
}
f = inputFiles[nextFile++];
- name = f.FullName + "_" + iteration;
+ name = f.GetCanonicalPath() + "_" + iteration;
}
using (TextReader reader = new StreamReader(new FileStream(f.FullName, FileMode.Open, FileAccess.Read), Encoding.UTF8))
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5d9a9a04/src/Lucene.Net.Tests.Benchmark/ByTask/Feeds/TrecContentSourceTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Benchmark/ByTask/Feeds/TrecContentSourceTest.cs b/src/Lucene.Net.Tests.Benchmark/ByTask/Feeds/TrecContentSourceTest.cs
index d83bb5a..2ae8d68 100644
--- a/src/Lucene.Net.Tests.Benchmark/ByTask/Feeds/TrecContentSourceTest.cs
+++ b/src/Lucene.Net.Tests.Benchmark/ByTask/Feeds/TrecContentSourceTest.cs
@@ -1,5 +1,6 @@
using Lucene.Net.Benchmarks.ByTask.Utils;
using Lucene.Net.Documents;
+using Lucene.Net.Support.IO;
using Lucene.Net.Util;
using NUnit.Framework;
using System;
@@ -374,7 +375,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Feeds
props["content.source.verbose"] = "false";
props["content.source.excludeIteration"] = "true";
props["doc.maker.forever"] = "false";
- props["docs.dir"] = dataDir.FullName.Replace('\\', '/');
+ props["docs.dir"] = dataDir.GetCanonicalPath().Replace('\\', '/');
props["trec.doc.parser"] = typeof(TrecParserByPath).AssemblyQualifiedName;
props["content.source.forever"] = "false";
tcs.SetConfig(new Config(props));
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5d9a9a04/src/Lucene.Net/Store/FSDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Store/FSDirectory.cs b/src/Lucene.Net/Store/FSDirectory.cs
index 4c408ae..6cc3caf 100644
--- a/src/Lucene.Net/Store/FSDirectory.cs
+++ b/src/Lucene.Net/Store/FSDirectory.cs
@@ -1,9 +1,9 @@
+using Lucene.Net.Support.IO;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;// Used only for WRITE_LOCK_NAME in deprecated create=true case:
-using Lucene.Net.Support;
namespace Lucene.Net.Store
{
@@ -118,7 +118,7 @@ namespace Lucene.Net.Store
{
lockFactory = new NativeFSLockFactory();
}
- m_directory = path; // Lucene.NET doesn't need to call GetCanonicalPath since we already have DirectoryInfo handy
+ m_directory = new DirectoryInfo(path.GetCanonicalPath());
if (File.Exists(path.FullName))
{
@@ -215,7 +215,7 @@ namespace Lucene.Net.Store
lf.SetLockDir(m_directory);
lf.LockPrefix = null;
}
- else if (dir.FullName.Equals(m_directory.FullName, StringComparison.Ordinal))
+ else if (dir.GetCanonicalPath().Equals(m_directory.GetCanonicalPath(), StringComparison.Ordinal))
{
lf.LockPrefix = null;
}
@@ -395,7 +395,7 @@ namespace Lucene.Net.Store
string dirName; // name to be hashed
try
{
- dirName = m_directory.FullName;
+ dirName = m_directory.GetCanonicalPath();
}
catch (IOException e)
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5d9a9a04/src/Lucene.Net/Store/NativeFSLockFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Store/NativeFSLockFactory.cs b/src/Lucene.Net/Store/NativeFSLockFactory.cs
index ca2a158..bdf0dc4 100644
--- a/src/Lucene.Net/Store/NativeFSLockFactory.cs
+++ b/src/Lucene.Net/Store/NativeFSLockFactory.cs
@@ -1,3 +1,4 @@
+using Lucene.Net.Support.IO;
using Lucene.Net.Util;
using System;
using System.IO;
@@ -96,18 +97,18 @@ namespace Lucene.Net.Store
/// </summary>
/// <param name="lockName"></param>
/// <returns></returns>
- private string GetPathOfLockFile(string lockName)
+ private string GetCanonicalPathOfLockFile(string lockName)
{
if (m_lockPrefix != null)
{
lockName = m_lockPrefix + "-" + lockName;
}
- return Path.Combine(m_lockDir.FullName, lockName);
+ return new FileInfo(Path.Combine(m_lockDir.FullName, lockName)).GetCanonicalPath();
}
public override Lock MakeLock(string lockName)
{
- var path = GetPathOfLockFile(lockName);
+ var path = GetCanonicalPathOfLockFile(lockName);
NativeFSLock l;
lock (_locks)
if (!_locks.TryGetValue(path, out l))
@@ -117,7 +118,7 @@ namespace Lucene.Net.Store
public override void ClearLock(string lockName)
{
- var path = GetPathOfLockFile(lockName);
+ var path = GetCanonicalPathOfLockFile(lockName);
NativeFSLock l;
// this is the reason why we can't use ConcurrentDictionary: we need the removal and disposal of the lock to be atomic
// otherwise it may clash with MakeLock making a lock and ClearLock disposing of it in another thread.