@@ -177,9 +177,16 @@ class RepositoryObjectFactory(val localPath: String, val skipCleanup: Boolean)
177177 new Path (MD5Gen .str(path), remotePath.getName)
178178 )
179179 )
180- if (! fs.exists(localRepoPath)) {
180+
181+ val (remoteCopyPath, localCopyPath) = if (isBare) {
182+ (new Path (path), localRepoPath)
183+ } else {
184+ (new Path (path, " .git" ), new Path (localRepoPath, " .git" ))
185+ }
186+
187+ if (! fs.exists(localCopyPath)) {
181188 import RepositoryProvider .HadoopFsRecursiveCopier
182- fs.copyToLocalDir(new Path (path), localRepoPath )
189+ fs.copyToLocalDir(remoteCopyPath, localCopyPath )
183190 }
184191
185192 (localRepoPath, false )
@@ -193,11 +200,6 @@ class RepositoryObjectFactory(val localPath: String, val skipCleanup: Boolean)
193200 new File (localRepoPath.toString, " .git" )
194201 }).build()
195202
196- if (! skipCleanup && ! isLocalPath) {
197- log.debug(s " Delete $localRepoPath" )
198- FileUtils .deleteQuietly(Paths .get(localRepoPath.toString).toFile)
199- }
200-
201203 repo
202204 }
203205
@@ -357,10 +359,14 @@ object RepositoryProvider {
357359 val iter = fs.listFiles(src, true )
358360 while (iter.hasNext) {
359361 val f = iter.next
360- val dstPath = new Path (dst.toString, f.getPath.toString.substring(src.toString.length))
362+ // handle the case when file path starts with / correctly
363+ var fPath = f.getPath.toString.substring(src.toString.length)
364+ if (fPath.startsWith(" /" )) {
365+ fPath = fPath.substring(1 )
366+ }
367+ val dstPath = new Path (dst.toString, fPath)
361368 fs.copyToLocalFile(f.getPath, dstPath)
362369 }
363-
364370 }
365371
366372 }
0 commit comments