Skip to content

Commit 79d05a0

Browse files
authored
Merge pull request #428 from smacker/support_for_remote_standard_repos
fix support for remote standard repositories
2 parents 397832a + b7ebc35 commit 79d05a0

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/main/scala/tech/sourced/engine/provider/RepositoryProvider.scala

+15-9
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)