Fossil SCM
Update Windows version of vfile_check_signature() to get symlink status from manifest.symlinks
Commit
23e67f67d0fb5ea2a773d47cb4c4096fa0bebdc597828338b68085c1d44f5db2
Parent
03ba3d9cb29f8db…
1 file changed
+19
-5
+19
-5
| --- src/vfile.c | ||
| +++ src/vfile.c | ||
| @@ -173,10 +173,16 @@ | ||
| 173 | 173 | void vfile_check_signature(int vid, unsigned int cksigFlags){ |
| 174 | 174 | int nErr = 0; |
| 175 | 175 | Stmt q; |
| 176 | 176 | int useMtime = (cksigFlags & CKSIG_HASH)==0 |
| 177 | 177 | && db_get_boolean("mtime-changes", 1); |
| 178 | + | |
| 179 | + /* On Windows, get symlink permission status from the "manifest.symlinks" file | |
| 180 | + * if it exists and if the "manifest" setting contains the "l" flag. */ | |
| 181 | +#ifdef _WIN32 | |
| 182 | + int manifestSymlinks = get_checkout_symlink_table(); | |
| 183 | +#endif | |
| 178 | 184 | |
| 179 | 185 | db_begin_transaction(); |
| 180 | 186 | db_prepare(&q, "SELECT id, %Q || pathname," |
| 181 | 187 | " vfile.mrid, deleted, chnged, uuid, size, mtime," |
| 182 | 188 | " CASE WHEN isexe THEN %d WHEN islink THEN %d ELSE %d END" |
| @@ -186,14 +192,12 @@ | ||
| 186 | 192 | while( db_step(&q)==SQLITE_ROW ){ |
| 187 | 193 | int id, rid, isDeleted; |
| 188 | 194 | const char *zName; |
| 189 | 195 | int chnged = 0; |
| 190 | 196 | int oldChnged; |
| 191 | -#ifndef _WIN32 | |
| 192 | 197 | int origPerm; |
| 193 | 198 | int currentPerm; |
| 194 | -#endif | |
| 195 | 199 | i64 oldMtime; |
| 196 | 200 | i64 currentMtime; |
| 197 | 201 | i64 origSize; |
| 198 | 202 | i64 currentSize; |
| 199 | 203 | |
| @@ -204,12 +208,22 @@ | ||
| 204 | 208 | oldChnged = chnged = db_column_int(&q, 4); |
| 205 | 209 | oldMtime = db_column_int64(&q, 7); |
| 206 | 210 | origSize = db_column_int64(&q, 6); |
| 207 | 211 | currentSize = file_wd_size(zName); |
| 208 | 212 | currentMtime = file_wd_mtime(0); |
| 209 | -#ifndef _WIN32 | |
| 210 | 213 | origPerm = db_column_int(&q, 8); |
| 214 | +#ifdef _WIN32 | |
| 215 | + /* For Windows, if the "manifest" setting contains the "l" flag and the | |
| 216 | + * "manifest.symlinks" file exists, use its contents to determine which | |
| 217 | + * files do and do not have the symlink permission. */ | |
| 218 | + if( manifestSymlinks | |
| 219 | + && db_exists("SELECT 1 FROM symlink_perm WHERE filename=%Q", zName) ){ | |
| 220 | + currentPerm = PERM_LNK; | |
| 221 | + }else{ | |
| 222 | + currentPerm = 0; | |
| 223 | + } | |
| 224 | +#else | |
| 211 | 225 | currentPerm = file_wd_perm(zName); |
| 212 | 226 | #endif |
| 213 | 227 | if( chnged==0 && (isDeleted || rid==0) ){ |
| 214 | 228 | /* "fossil rm" or "fossil add" always change the file */ |
| 215 | 229 | chnged = 1; |
| @@ -251,27 +265,27 @@ | ||
| 251 | 265 | file_set_mtime(zName, desiredMtime); |
| 252 | 266 | currentMtime = file_wd_mtime(zName); |
| 253 | 267 | } |
| 254 | 268 | } |
| 255 | 269 | } |
| 256 | -#ifndef _WIN32 | |
| 257 | 270 | if( origPerm!=PERM_LNK && currentPerm==PERM_LNK ){ |
| 258 | 271 | /* Changing to a symlink takes priority over all other change types. */ |
| 259 | 272 | chnged = 7; |
| 260 | 273 | }else if( chnged==0 || chnged==6 || chnged==7 || chnged==8 || chnged==9 ){ |
| 261 | 274 | /* Confirm metadata change types. */ |
| 262 | 275 | if( origPerm==currentPerm ){ |
| 263 | 276 | chnged = 0; |
| 277 | +#ifndef _WIN32 | |
| 264 | 278 | }else if( currentPerm==PERM_EXE ){ |
| 265 | 279 | chnged = 6; |
| 266 | 280 | }else if( origPerm==PERM_EXE ){ |
| 267 | 281 | chnged = 8; |
| 282 | +#endif | |
| 268 | 283 | }else if( origPerm==PERM_LNK ){ |
| 269 | 284 | chnged = 9; |
| 270 | 285 | } |
| 271 | 286 | } |
| 272 | -#endif | |
| 273 | 287 | if( currentMtime!=oldMtime || chnged!=oldChnged ){ |
| 274 | 288 | db_multi_exec("UPDATE vfile SET mtime=%lld, chnged=%d WHERE id=%d", |
| 275 | 289 | currentMtime, chnged, id); |
| 276 | 290 | } |
| 277 | 291 | } |
| 278 | 292 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -173,10 +173,16 @@ | |
| 173 | void vfile_check_signature(int vid, unsigned int cksigFlags){ |
| 174 | int nErr = 0; |
| 175 | Stmt q; |
| 176 | int useMtime = (cksigFlags & CKSIG_HASH)==0 |
| 177 | && db_get_boolean("mtime-changes", 1); |
| 178 | |
| 179 | db_begin_transaction(); |
| 180 | db_prepare(&q, "SELECT id, %Q || pathname," |
| 181 | " vfile.mrid, deleted, chnged, uuid, size, mtime," |
| 182 | " CASE WHEN isexe THEN %d WHEN islink THEN %d ELSE %d END" |
| @@ -186,14 +192,12 @@ | |
| 186 | while( db_step(&q)==SQLITE_ROW ){ |
| 187 | int id, rid, isDeleted; |
| 188 | const char *zName; |
| 189 | int chnged = 0; |
| 190 | int oldChnged; |
| 191 | #ifndef _WIN32 |
| 192 | int origPerm; |
| 193 | int currentPerm; |
| 194 | #endif |
| 195 | i64 oldMtime; |
| 196 | i64 currentMtime; |
| 197 | i64 origSize; |
| 198 | i64 currentSize; |
| 199 | |
| @@ -204,12 +208,22 @@ | |
| 204 | oldChnged = chnged = db_column_int(&q, 4); |
| 205 | oldMtime = db_column_int64(&q, 7); |
| 206 | origSize = db_column_int64(&q, 6); |
| 207 | currentSize = file_wd_size(zName); |
| 208 | currentMtime = file_wd_mtime(0); |
| 209 | #ifndef _WIN32 |
| 210 | origPerm = db_column_int(&q, 8); |
| 211 | currentPerm = file_wd_perm(zName); |
| 212 | #endif |
| 213 | if( chnged==0 && (isDeleted || rid==0) ){ |
| 214 | /* "fossil rm" or "fossil add" always change the file */ |
| 215 | chnged = 1; |
| @@ -251,27 +265,27 @@ | |
| 251 | file_set_mtime(zName, desiredMtime); |
| 252 | currentMtime = file_wd_mtime(zName); |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | #ifndef _WIN32 |
| 257 | if( origPerm!=PERM_LNK && currentPerm==PERM_LNK ){ |
| 258 | /* Changing to a symlink takes priority over all other change types. */ |
| 259 | chnged = 7; |
| 260 | }else if( chnged==0 || chnged==6 || chnged==7 || chnged==8 || chnged==9 ){ |
| 261 | /* Confirm metadata change types. */ |
| 262 | if( origPerm==currentPerm ){ |
| 263 | chnged = 0; |
| 264 | }else if( currentPerm==PERM_EXE ){ |
| 265 | chnged = 6; |
| 266 | }else if( origPerm==PERM_EXE ){ |
| 267 | chnged = 8; |
| 268 | }else if( origPerm==PERM_LNK ){ |
| 269 | chnged = 9; |
| 270 | } |
| 271 | } |
| 272 | #endif |
| 273 | if( currentMtime!=oldMtime || chnged!=oldChnged ){ |
| 274 | db_multi_exec("UPDATE vfile SET mtime=%lld, chnged=%d WHERE id=%d", |
| 275 | currentMtime, chnged, id); |
| 276 | } |
| 277 | } |
| 278 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -173,10 +173,16 @@ | |
| 173 | void vfile_check_signature(int vid, unsigned int cksigFlags){ |
| 174 | int nErr = 0; |
| 175 | Stmt q; |
| 176 | int useMtime = (cksigFlags & CKSIG_HASH)==0 |
| 177 | && db_get_boolean("mtime-changes", 1); |
| 178 | |
| 179 | /* On Windows, get symlink permission status from the "manifest.symlinks" file |
| 180 | * if it exists and if the "manifest" setting contains the "l" flag. */ |
| 181 | #ifdef _WIN32 |
| 182 | int manifestSymlinks = get_checkout_symlink_table(); |
| 183 | #endif |
| 184 | |
| 185 | db_begin_transaction(); |
| 186 | db_prepare(&q, "SELECT id, %Q || pathname," |
| 187 | " vfile.mrid, deleted, chnged, uuid, size, mtime," |
| 188 | " CASE WHEN isexe THEN %d WHEN islink THEN %d ELSE %d END" |
| @@ -186,14 +192,12 @@ | |
| 192 | while( db_step(&q)==SQLITE_ROW ){ |
| 193 | int id, rid, isDeleted; |
| 194 | const char *zName; |
| 195 | int chnged = 0; |
| 196 | int oldChnged; |
| 197 | int origPerm; |
| 198 | int currentPerm; |
| 199 | i64 oldMtime; |
| 200 | i64 currentMtime; |
| 201 | i64 origSize; |
| 202 | i64 currentSize; |
| 203 | |
| @@ -204,12 +208,22 @@ | |
| 208 | oldChnged = chnged = db_column_int(&q, 4); |
| 209 | oldMtime = db_column_int64(&q, 7); |
| 210 | origSize = db_column_int64(&q, 6); |
| 211 | currentSize = file_wd_size(zName); |
| 212 | currentMtime = file_wd_mtime(0); |
| 213 | origPerm = db_column_int(&q, 8); |
| 214 | #ifdef _WIN32 |
| 215 | /* For Windows, if the "manifest" setting contains the "l" flag and the |
| 216 | * "manifest.symlinks" file exists, use its contents to determine which |
| 217 | * files do and do not have the symlink permission. */ |
| 218 | if( manifestSymlinks |
| 219 | && db_exists("SELECT 1 FROM symlink_perm WHERE filename=%Q", zName) ){ |
| 220 | currentPerm = PERM_LNK; |
| 221 | }else{ |
| 222 | currentPerm = 0; |
| 223 | } |
| 224 | #else |
| 225 | currentPerm = file_wd_perm(zName); |
| 226 | #endif |
| 227 | if( chnged==0 && (isDeleted || rid==0) ){ |
| 228 | /* "fossil rm" or "fossil add" always change the file */ |
| 229 | chnged = 1; |
| @@ -251,27 +265,27 @@ | |
| 265 | file_set_mtime(zName, desiredMtime); |
| 266 | currentMtime = file_wd_mtime(zName); |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | if( origPerm!=PERM_LNK && currentPerm==PERM_LNK ){ |
| 271 | /* Changing to a symlink takes priority over all other change types. */ |
| 272 | chnged = 7; |
| 273 | }else if( chnged==0 || chnged==6 || chnged==7 || chnged==8 || chnged==9 ){ |
| 274 | /* Confirm metadata change types. */ |
| 275 | if( origPerm==currentPerm ){ |
| 276 | chnged = 0; |
| 277 | #ifndef _WIN32 |
| 278 | }else if( currentPerm==PERM_EXE ){ |
| 279 | chnged = 6; |
| 280 | }else if( origPerm==PERM_EXE ){ |
| 281 | chnged = 8; |
| 282 | #endif |
| 283 | }else if( origPerm==PERM_LNK ){ |
| 284 | chnged = 9; |
| 285 | } |
| 286 | } |
| 287 | if( currentMtime!=oldMtime || chnged!=oldChnged ){ |
| 288 | db_multi_exec("UPDATE vfile SET mtime=%lld, chnged=%d WHERE id=%d", |
| 289 | currentMtime, chnged, id); |
| 290 | } |
| 291 | } |
| 292 |