[Midnightbsd-cvs] src [7090] trunk/lib/libmport/delete_primative.c: delete sample file if it matches md5 hash

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Tue Jul 14 21:45:46 EDT 2015


Revision: 7090
          http://svnweb.midnightbsd.org/src/?rev=7090
Author:   laffer1
Date:     2015-07-14 21:45:45 -0400 (Tue, 14 Jul 2015)
Log Message:
-----------
delete sample file if it matches md5 hash

Modified Paths:
--------------
    trunk/lib/libmport/delete_primative.c

Modified: trunk/lib/libmport/delete_primative.c
===================================================================
--- trunk/lib/libmport/delete_primative.c	2015-07-15 01:28:03 UTC (rev 7089)
+++ trunk/lib/libmport/delete_primative.c	2015-07-15 01:45:45 UTC (rev 7090)
@@ -151,13 +151,11 @@
       case ASSET_SAMPLE:
         (mport->progress_step_cb)(++current, total, file);
         
-      
         if (lstat(file, &st) != 0) {
           mport_call_msg_cb(mport, "Can't stat %s: %s", file, strerror(errno));
           break; /* next asset */
         } 
         
-        
         if (S_ISREG(st.st_mode)) {
           if (MD5File(file, md5) == NULL) 
             mport_call_msg_cb(mport, "Can't md5 %s: %s", file, strerror(errno));
@@ -164,6 +162,24 @@
           
           if (strcmp(md5, checksum) != 0) 
             mport_call_msg_cb(mport, "Checksum mismatch: %s", file);
+
+          if (type == ASSET_SAMPLE) {
+              char sample_md5[33];
+              char nonSample[FILENAME_MAX];
+              strlcpy(nonSample, file, FILENAME_MAX);
+              char *sptr = strcasestr(file, ".sample");
+              if (sptr != NULL) {
+                  sptr[0] = '\0'; /* hack off .sample */
+                  if (MD5File(nonSample, sample_md5) == NULL) {
+                      mport_call_msg_cb(mport, "File does not match sample, remove file %s manually.", nonSample);
+                  } else {
+                      if (strcmp(sample_md5, md5) == 0) {
+		          if (unlink(nonSample) != 0)
+          	   	    mport_call_msg_cb(mport, "Could not unlink %s: %s", file, strerror(errno));
+		      } 
+                  }
+              }
+          }
         }
         
         if (unlink(file) != 0) 



More information about the Midnightbsd-cvs mailing list