comparison src/org/tmatesoft/hg/internal/StoragePathHelper.java @ 346:6d2c6b2469fc

Issue 18: Invalid storage path for certain long names
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 22 Nov 2011 04:02:37 +0100
parents a415fe296a50
children 464b4404e75d
comparison
equal deleted inserted replaced
345:58725dd511b3 346:6d2c6b2469fc
139 } while (x < fnameStart); 139 } while (x < fnameStart);
140 assert sb2.charAt(sb2.length() - 1) == '/'; 140 assert sb2.charAt(sb2.length() - 1) == '/';
141 int left = MAX_PATH_LEN - sb2.length() - 40 /*digest.length()*/ - STR_DH.length() - ".i".length(); 141 int left = MAX_PATH_LEN - sb2.length() - 40 /*digest.length()*/ - STR_DH.length() - ".i".length();
142 assert left >= 0; 142 assert left >= 0;
143 fnameStart++; // move from / to actual name 143 fnameStart++; // move from / to actual name
144 sb2.append(sb, fnameStart, fnameStart + left > sb.length() ? sb.length() : fnameStart+left); 144 if (fnameStart + left > sb.length()) {
145 // there left less chars in the mangled name that we can fit
146 sb2.append(sb, fnameStart, sb.length());
147 int stillAvailable = (fnameStart+left) - sb.length();
148 // stillAvailable > 0;
149 sb2.append(".i", 0, stillAvailable > 2 ? 2 : stillAvailable);
150 } else {
151 // add as much as we can
152 sb2.append(sb, fnameStart, fnameStart+left);
153 }
145 completeHashName.append(sb2); 154 completeHashName.append(sb2);
146 } 155 }
147 completeHashName.append(digest); 156 completeHashName.append(digest);
148 sb = completeHashName; 157 sb = completeHashName;
149 } else if (store) { 158 } else if (store) {