Fossil SCM

More robust detection of top of a checkout in the dir_has_ckout_db() function.

drh 2024-12-11 00:32 trunk
Commit 36f916c504c525c72f48585e844aa6bfda22a401f3297d21611cb1fd0fecd041
1 file changed +4
+4
--- src/file.c
+++ src/file.c
@@ -2973,19 +2973,23 @@
29732973
** Returns 1 if the given directory contains a file named .fslckout, 2
29742974
** if it contains a file named _FOSSIL_, else returns 0.
29752975
*/
29762976
int dir_has_ckout_db(const char *zDir){
29772977
int rc = 0;
2978
+ i64 sz;
29782979
char * zCkoutDb = mprintf("%//.fslckout", zDir);
29792980
if(file_isfile(zCkoutDb, ExtFILE)){
29802981
rc = 1;
29812982
}else{
29822983
fossil_free(zCkoutDb);
29832984
zCkoutDb = mprintf("%//_FOSSIL_", zDir);
29842985
if(file_isfile(zCkoutDb, ExtFILE)){
29852986
rc = 2;
29862987
}
2988
+ }
2989
+ if( rc && ((sz = file_size(zCkoutDb, ExtFILE))<1024 || (sz%512)!=0) ){
2990
+ rc = 0;
29872991
}
29882992
fossil_free(zCkoutDb);
29892993
return rc;
29902994
}
29912995
29922996
--- src/file.c
+++ src/file.c
@@ -2973,19 +2973,23 @@
2973 ** Returns 1 if the given directory contains a file named .fslckout, 2
2974 ** if it contains a file named _FOSSIL_, else returns 0.
2975 */
2976 int dir_has_ckout_db(const char *zDir){
2977 int rc = 0;
 
2978 char * zCkoutDb = mprintf("%//.fslckout", zDir);
2979 if(file_isfile(zCkoutDb, ExtFILE)){
2980 rc = 1;
2981 }else{
2982 fossil_free(zCkoutDb);
2983 zCkoutDb = mprintf("%//_FOSSIL_", zDir);
2984 if(file_isfile(zCkoutDb, ExtFILE)){
2985 rc = 2;
2986 }
 
 
 
2987 }
2988 fossil_free(zCkoutDb);
2989 return rc;
2990 }
2991
2992
--- src/file.c
+++ src/file.c
@@ -2973,19 +2973,23 @@
2973 ** Returns 1 if the given directory contains a file named .fslckout, 2
2974 ** if it contains a file named _FOSSIL_, else returns 0.
2975 */
2976 int dir_has_ckout_db(const char *zDir){
2977 int rc = 0;
2978 i64 sz;
2979 char * zCkoutDb = mprintf("%//.fslckout", zDir);
2980 if(file_isfile(zCkoutDb, ExtFILE)){
2981 rc = 1;
2982 }else{
2983 fossil_free(zCkoutDb);
2984 zCkoutDb = mprintf("%//_FOSSIL_", zDir);
2985 if(file_isfile(zCkoutDb, ExtFILE)){
2986 rc = 2;
2987 }
2988 }
2989 if( rc && ((sz = file_size(zCkoutDb, ExtFILE))<1024 || (sz%512)!=0) ){
2990 rc = 0;
2991 }
2992 fossil_free(zCkoutDb);
2993 return rc;
2994 }
2995
2996

Keyboard Shortcuts

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