Checkout should not use too long filenames
DirCacheCheckout is generating names for temporary files. It was not checking the length of this filenames. It may happen that a generated filename is longer than 255 chars which causes problems on certain platforms. Make sure that filenames for temporary files do not exceed 255 chars. Bug: 508823 Change-Id: I9475c04351ce3faebdc6ad40ea4faa3c326815f4
This commit is contained in:
parent
5b84e25fa3
commit
501af12c19
|
@ -1672,6 +1672,20 @@ public void testFolderFileAndContentConflicts() throws Exception {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongFilename() throws Exception {
|
||||
char[] bytes = new char[253];
|
||||
Arrays.fill(bytes, 'f');
|
||||
String longFileName = new String(bytes);
|
||||
// 1
|
||||
doit(mkmap(longFileName, "a"), mkmap(longFileName, "b"),
|
||||
mkmap(longFileName, "a"));
|
||||
writeTrashFile(longFileName, "a");
|
||||
checkout();
|
||||
assertNoConflicts();
|
||||
assertUpdated(longFileName);
|
||||
}
|
||||
|
||||
public void assertWorkDir(Map<String, String> i)
|
||||
throws CorruptObjectException,
|
||||
IOException {
|
||||
|
|
|
@ -1299,8 +1299,13 @@ public static void checkoutEntry(Repository repo, DirCacheEntry entry,
|
|||
return;
|
||||
}
|
||||
|
||||
String name = f.getName();
|
||||
if (name.length() > 200) {
|
||||
name = name.substring(0, 200);
|
||||
}
|
||||
File tmpFile = File.createTempFile(
|
||||
"._" + f.getName(), null, parentDir); //$NON-NLS-1$
|
||||
"._" + name, null, parentDir); //$NON-NLS-1$
|
||||
|
||||
EolStreamType nonNullEolStreamType;
|
||||
if (checkoutMetadata.eolStreamType != null) {
|
||||
nonNullEolStreamType = checkoutMetadata.eolStreamType;
|
||||
|
|
Loading…
Reference in New Issue