# --- T2-COPYRIGHT-BEGIN --- # t2/package/*/mine/hotfix-check-file-unlink.patch # Copyright (C) 2006-2016 The T2 SDE Project # SPDX-License-Identifier: GPL-2.0 or patched project license # --- T2-COPYRIGHT-END --- This fixes detecting unliked (removed, deleted) files as modified. - Rene Rebe --- mine-0.23/md5sum.c.orig 2016-03-23 23:08:37.515390469 +0100 +++ mine-0.23/md5sum.c 2016-03-23 23:20:45.379405046 +0100 @@ -1,6 +1,7 @@ /* * GEM MINE - The ROCK Linux Package Manager * Copyright (C) 2002-2005 Clifford Wolf + * Copyright (C) 2006-2016 Rene Rebe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,11 +35,11 @@ char * md5sum_create(char * root, char * filename) { char realfilename[1024]; - struct stat statbuf; + struct stat st; snprintf(realfilename, 1024, "%s/%s", root, filename); - return (stat(realfilename, &statbuf) != 0 || S_ISFIFO(statbuf.st_mode)) - ? "" : md5_file(realfilename); + return (!lstat(realfilename, &st) && S_ISREG(st.st_mode) ? + md5_file(realfilename) : ""); } /* Returns 1 if file is duplicate, 2 if file is modified. */ @@ -48,9 +49,14 @@ md5_f = md5sum_create(root, filename); md5_d = memdb_get(&md5_memdb, filename); - - if (md5_f == NULL || strcmp(md5_f, "") == 0) - return 0; + + /* this is a bit tricky, directory also have no hash! */ + if (md5_f == NULL || strcmp(md5_f, "") == 0) { + if (md5_d == NULL || strcmp(md5_d, "") == 0) + return 0; /* directory or symlink, no hash in db */ + else + return 2; /* modified, was removed */ + } else if (md5_d == NULL) return 1; else if (strcmp(md5_f, md5_d) == 0)