Fossil SCM

Update Windows version of vfile_check_signature() to get symlink status from manifest.symlinks

andygoth 2017-10-14 21:43 UTC andygoth-enhanced-symlink
Commit 23e67f67d0fb5ea2a773d47cb4c4096fa0bebdc597828338b68085c1d44f5db2
1 file changed +19 -5
+19 -5
--- src/vfile.c
+++ src/vfile.c
@@ -173,10 +173,16 @@
173173
void vfile_check_signature(int vid, unsigned int cksigFlags){
174174
int nErr = 0;
175175
Stmt q;
176176
int useMtime = (cksigFlags & CKSIG_HASH)==0
177177
&& 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
178184
179185
db_begin_transaction();
180186
db_prepare(&q, "SELECT id, %Q || pathname,"
181187
" vfile.mrid, deleted, chnged, uuid, size, mtime,"
182188
" CASE WHEN isexe THEN %d WHEN islink THEN %d ELSE %d END"
@@ -186,14 +192,12 @@
186192
while( db_step(&q)==SQLITE_ROW ){
187193
int id, rid, isDeleted;
188194
const char *zName;
189195
int chnged = 0;
190196
int oldChnged;
191
-#ifndef _WIN32
192197
int origPerm;
193198
int currentPerm;
194
-#endif
195199
i64 oldMtime;
196200
i64 currentMtime;
197201
i64 origSize;
198202
i64 currentSize;
199203
@@ -204,12 +208,22 @@
204208
oldChnged = chnged = db_column_int(&q, 4);
205209
oldMtime = db_column_int64(&q, 7);
206210
origSize = db_column_int64(&q, 6);
207211
currentSize = file_wd_size(zName);
208212
currentMtime = file_wd_mtime(0);
209
-#ifndef _WIN32
210213
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
211225
currentPerm = file_wd_perm(zName);
212226
#endif
213227
if( chnged==0 && (isDeleted || rid==0) ){
214228
/* "fossil rm" or "fossil add" always change the file */
215229
chnged = 1;
@@ -251,27 +265,27 @@
251265
file_set_mtime(zName, desiredMtime);
252266
currentMtime = file_wd_mtime(zName);
253267
}
254268
}
255269
}
256
-#ifndef _WIN32
257270
if( origPerm!=PERM_LNK && currentPerm==PERM_LNK ){
258271
/* Changing to a symlink takes priority over all other change types. */
259272
chnged = 7;
260273
}else if( chnged==0 || chnged==6 || chnged==7 || chnged==8 || chnged==9 ){
261274
/* Confirm metadata change types. */
262275
if( origPerm==currentPerm ){
263276
chnged = 0;
277
+#ifndef _WIN32
264278
}else if( currentPerm==PERM_EXE ){
265279
chnged = 6;
266280
}else if( origPerm==PERM_EXE ){
267281
chnged = 8;
282
+#endif
268283
}else if( origPerm==PERM_LNK ){
269284
chnged = 9;
270285
}
271286
}
272
-#endif
273287
if( currentMtime!=oldMtime || chnged!=oldChnged ){
274288
db_multi_exec("UPDATE vfile SET mtime=%lld, chnged=%d WHERE id=%d",
275289
currentMtime, chnged, id);
276290
}
277291
}
278292
--- 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

Keyboard Shortcuts

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