Skip to content

Commit

Permalink
Merge pull request #428 from smacker/support_for_remote_standard_repos
Browse files Browse the repository at this point in the history
fix support for remote standard repositories
  • Loading branch information
ajnavarro authored Feb 7, 2019
2 parents 397832a + b7ebc35 commit 79d05a0
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,16 @@ class RepositoryObjectFactory(val localPath: String, val skipCleanup: Boolean)
new Path(MD5Gen.str(path), remotePath.getName)
)
)
if (!fs.exists(localRepoPath)) {

val (remoteCopyPath, localCopyPath) = if (isBare) {
(new Path(path), localRepoPath)
} else {
(new Path(path, ".git"), new Path(localRepoPath, ".git"))
}

if (!fs.exists(localCopyPath)) {
import RepositoryProvider.HadoopFsRecursiveCopier
fs.copyToLocalDir(new Path(path), localRepoPath)
fs.copyToLocalDir(remoteCopyPath, localCopyPath)
}

(localRepoPath, false)
Expand All @@ -193,11 +200,6 @@ class RepositoryObjectFactory(val localPath: String, val skipCleanup: Boolean)
new File(localRepoPath.toString, ".git")
}).build()

if (!skipCleanup && !isLocalPath) {
log.debug(s"Delete $localRepoPath")
FileUtils.deleteQuietly(Paths.get(localRepoPath.toString).toFile)
}

repo
}

Expand Down Expand Up @@ -357,10 +359,14 @@ object RepositoryProvider {
val iter = fs.listFiles(src, true)
while (iter.hasNext) {
val f = iter.next
val dstPath = new Path(dst.toString, f.getPath.toString.substring(src.toString.length))
// handle the case when file path starts with / correctly
var fPath = f.getPath.toString.substring(src.toString.length)
if (fPath.startsWith("/")) {
fPath = fPath.substring(1)
}
val dstPath = new Path(dst.toString, fPath)
fs.copyToLocalFile(f.getPath, dstPath)
}

}

}
Expand Down

0 comments on commit 79d05a0

Please sign in to comment.