WalkPushConnection: Sanitize paths given to transports
These paths are given to the underlying URI-based transports (s3, sftp, http), all of which expect forward-slash as the path separator character. Change-Id: I3cbb5928c9531a4da4691411bd8ac248fdf47ef2
This commit is contained in:
parent
61f4a036c6
commit
514ebfdc7e
|
@ -230,7 +230,7 @@ private void sendpack(final List<RemoteRefUpdate> updates,
|
|||
// offsets from appearing to clients.
|
||||
//
|
||||
dest.writeInfoPacks(packNames.keySet());
|
||||
dest.deleteFile(idx.getPath());
|
||||
dest.deleteFile(sanitizedPath(idx));
|
||||
}
|
||||
|
||||
// Write the pack file, then the index, as readers look the
|
||||
|
@ -238,13 +238,13 @@ private void sendpack(final List<RemoteRefUpdate> updates,
|
|||
//
|
||||
String wt = "Put " + pack.getName().substring(0, 12); //$NON-NLS-1$
|
||||
try (OutputStream os = new BufferedOutputStream(
|
||||
dest.writeFile(pack.getPath(), monitor,
|
||||
dest.writeFile(sanitizedPath(pack), monitor,
|
||||
wt + "." + pack.getPackExt().getExtension()))) { //$NON-NLS-1$
|
||||
writer.writePack(monitor, monitor, os);
|
||||
}
|
||||
|
||||
try (OutputStream os = new BufferedOutputStream(
|
||||
dest.writeFile(idx.getPath(), monitor,
|
||||
dest.writeFile(sanitizedPath(idx), monitor,
|
||||
wt + "." + idx.getPackExt().getExtension()))) { //$NON-NLS-1$
|
||||
writer.writeIndex(os);
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ private void sendpack(final List<RemoteRefUpdate> updates,
|
|||
private void safeDelete(File path) {
|
||||
if (path != null) {
|
||||
try {
|
||||
dest.deleteFile(path.getPath());
|
||||
dest.deleteFile(sanitizedPath(path));
|
||||
} catch (IOException cleanupFailure) {
|
||||
// Ignore the deletion failure. We probably are
|
||||
// already failing and were just trying to pick
|
||||
|
@ -366,4 +366,13 @@ private static String pickHEAD(List<RemoteRefUpdate> updates) {
|
|||
}
|
||||
return updates.get(0).getRemoteName();
|
||||
}
|
||||
|
||||
private static String sanitizedPath(File file) {
|
||||
String path = file.getPath();
|
||||
if (File.separatorChar != '/') {
|
||||
path = path.replace(File.separatorChar, '/');
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue