@@ -177,9 +177,16 @@ class RepositoryObjectFactory(val localPath: String, val skipCleanup: Boolean)
177
177
new Path (MD5Gen .str(path), remotePath.getName)
178
178
)
179
179
)
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)) {
181
188
import RepositoryProvider .HadoopFsRecursiveCopier
182
- fs.copyToLocalDir(new Path (path), localRepoPath )
189
+ fs.copyToLocalDir(remoteCopyPath, localCopyPath )
183
190
}
184
191
185
192
(localRepoPath, false )
@@ -193,11 +200,6 @@ class RepositoryObjectFactory(val localPath: String, val skipCleanup: Boolean)
193
200
new File (localRepoPath.toString, " .git" )
194
201
}).build()
195
202
196
- if (! skipCleanup && ! isLocalPath) {
197
- log.debug(s " Delete $localRepoPath" )
198
- FileUtils .deleteQuietly(Paths .get(localRepoPath.toString).toFile)
199
- }
200
-
201
203
repo
202
204
}
203
205
@@ -357,10 +359,14 @@ object RepositoryProvider {
357
359
val iter = fs.listFiles(src, true )
358
360
while (iter.hasNext) {
359
361
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)
361
368
fs.copyToLocalFile(f.getPath, dstPath)
362
369
}
363
-
364
370
}
365
371
366
372
}
0 commit comments