# --- T2-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # T2 SDE: package/.../mine/check-file-unlink.patch # Copyright (C) 2006-2016 The T2 SDE Project # # More information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # --- T2-COPYRIGHT-NOTE-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)