Fossil SCM

When generating a tarball, remove the complete ".tar.gz" suffix from the filename to create the top-level directory name, not just the ".gz" part.

drh 2011-03-17 15:33 UTC trunk
Commit 9ca5bbf8a6d452abf2c4c896c74d6d81363f82de
1 file changed +12 -4
+12 -4
--- src/tar.c
+++ src/tar.c
@@ -309,14 +309,22 @@
309309
if( !g.okZip ){ login_needed(); return; }
310310
zName = mprintf("%s", PD("name",""));
311311
nName = strlen(zName);
312312
zRid = mprintf("%s", PD("uuid",""));
313313
nRid = strlen(zRid);
314
- for(nName=strlen(zName)-1; nName>5; nName--){
315
- if( zName[nName]=='.' ){
316
- zName[nName] = 0;
317
- break;
314
+ if( nName>7 && strcmp(&zName[nName-7], ".tar.gz")==0 ){
315
+ /* Special case: Remove the ".tar.gz" suffix. */
316
+ nName -= 7;
317
+ zName[nName] = 0;
318
+ }else{
319
+ /* If the file suffix is not ".tar.gz" then just remove the
320
+ ** suffix up to and including the last "." */
321
+ for(nName=strlen(zName)-1; nName>5; nName--){
322
+ if( zName[nName]=='.' ){
323
+ zName[nName] = 0;
324
+ break;
325
+ }
318326
}
319327
}
320328
rid = name_to_rid(nRid?zRid:zName);
321329
if( rid==0 ){
322330
@ Not found
323331
--- src/tar.c
+++ src/tar.c
@@ -309,14 +309,22 @@
309 if( !g.okZip ){ login_needed(); return; }
310 zName = mprintf("%s", PD("name",""));
311 nName = strlen(zName);
312 zRid = mprintf("%s", PD("uuid",""));
313 nRid = strlen(zRid);
314 for(nName=strlen(zName)-1; nName>5; nName--){
315 if( zName[nName]=='.' ){
316 zName[nName] = 0;
317 break;
 
 
 
 
 
 
 
 
318 }
319 }
320 rid = name_to_rid(nRid?zRid:zName);
321 if( rid==0 ){
322 @ Not found
323
--- src/tar.c
+++ src/tar.c
@@ -309,14 +309,22 @@
309 if( !g.okZip ){ login_needed(); return; }
310 zName = mprintf("%s", PD("name",""));
311 nName = strlen(zName);
312 zRid = mprintf("%s", PD("uuid",""));
313 nRid = strlen(zRid);
314 if( nName>7 && strcmp(&zName[nName-7], ".tar.gz")==0 ){
315 /* Special case: Remove the ".tar.gz" suffix. */
316 nName -= 7;
317 zName[nName] = 0;
318 }else{
319 /* If the file suffix is not ".tar.gz" then just remove the
320 ** suffix up to and including the last "." */
321 for(nName=strlen(zName)-1; nName>5; nName--){
322 if( zName[nName]=='.' ){
323 zName[nName] = 0;
324 break;
325 }
326 }
327 }
328 rid = name_to_rid(nRid?zRid:zName);
329 if( rid==0 ){
330 @ Not found
331

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button