Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

[REEF-1827] new Uri(path) in REEF.NET IO Returns Lowercase String #1329

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions lang/cs/Org.Apache.REEF.IO/FileSystem/Hadoop/HadoopFileSystem.cs
Expand Up @@ -72,12 +72,12 @@ public Uri CreateUriForPath(string path)
try
{
uri = new Uri(path);
Logger.Log(Level.Info, string.Format(CultureInfo.CurrentCulture, "Uri {0} created in CreateUriForPath.", uri));
Logger.Log(Level.Info, string.Format(CultureInfo.CurrentCulture, "Uri {0} created in CreateUriForPath.", uri.AbsolutePath));
}
catch (UriFormatException)
{
uri = new Uri(_uriPrefix + path);
Logger.Log(Level.Info, string.Format(CultureInfo.CurrentCulture, "Uri {0} created in CreateUriForPath with prefix added.", uri));
Logger.Log(Level.Info, string.Format(CultureInfo.CurrentCulture, "Uri {0} created in CreateUriForPath with prefix added.", uri.AbsolutePath));
}

return uri;
Expand Down Expand Up @@ -118,46 +118,46 @@ public Stream Create(Uri fileUri)
public void Delete(Uri fileUri)
{
// Delete the file via the hdfs command line.
_commandRunner.Run("dfs -rm " + fileUri);
_commandRunner.Run("dfs -rm " + fileUri.AbsolutePath);
}

public bool Exists(Uri fileUri)
{
// This determines the existence of a file based on the 'ls' command.
// Ideally, we'd use the 'test' command's return value, but we did not find a way to access that.
return
_commandRunner.Run("dfs -ls " + fileUri).StdErr
_commandRunner.Run("dfs -ls " + fileUri.AbsolutePath).StdErr
.All(line => !NoSuchFileOrDirectoryRegEx.IsMatch(line));
}

public void Copy(Uri sourceUri, Uri destinationUri)
{
_commandRunner.Run("dfs -cp " + sourceUri + " " + destinationUri);
_commandRunner.Run("dfs -cp " + sourceUri.AbsolutePath + " " + destinationUri.AbsolutePath);
}

public void CopyToLocal(Uri remoteFileUri, string localName)
{
_commandRunner.Run("dfs -get " + remoteFileUri + " " + localName);
_commandRunner.Run("dfs -get " + remoteFileUri.AbsolutePath + " " + localName);
}

public void CopyFromLocal(string localFileName, Uri remoteFileUri)
{
_commandRunner.Run("dfs -put " + localFileName + " " + remoteFileUri);
_commandRunner.Run("dfs -put " + localFileName + " " + remoteFileUri.AbsolutePath);
}

public void CreateDirectory(Uri directoryUri)
{
_commandRunner.Run("dfs -mkdir " + directoryUri);
_commandRunner.Run("dfs -mkdir " + directoryUri.AbsolutePath);
}

public void DeleteDirectory(Uri directoryUri)
{
_commandRunner.Run("dfs -rmdir " + directoryUri);
_commandRunner.Run("dfs -rmdir " + directoryUri.AbsolutePath);
}

public IEnumerable<Uri> GetChildren(Uri directoryUri)
{
return _commandRunner.Run("dfs -ls " + directoryUri)
return _commandRunner.Run("dfs -ls " + directoryUri.AbsolutePath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean even URI object converted the path into lower case, but uri.AbsolutePath will return case sensitive path, right?

.StdOut.Where(line => !LsFirstLineRegex.IsMatch(line))
.Select(line => line.Split())
.Select(x => new Uri(x[x.Length - 1]));
Expand Down