On Mon, Aug 14, 2006, EV wrote:
> 2006-08-14: EV dixit:
> > 2006-08-14: EV dixit:
> > Still another detail:  rio_rw, now part of the library, directly
> > writes on stdout: "File already present. Skipping...".  To be
> > consistent with the general libkarma policy, this has to be
> > handled through errors.c.
> > 
> > I can easyly change this and the other issues myself, if you 
> > agree.

This patch fixes the two issues reported.

> I'm just realizing that rio_rw.c contain a bunch of direct
> printf's.  Should I remove all of them (adding the necessary
> entries to erros.c -- and lkarma.h)?

Go ahead.

Keith.
# HG changeset patch
# User Keith Bennett <[EMAIL PROTECTED]>
# Node ID 0993af40f8e206aafc580860263b0ac99cc22c5f
# Parent  2991132d6692032598f5d4f136464adc1bbd6d90
Make dupe skipping optional.
Set a library error rather than printing to screen when a dupe is found.

diff -r 2991132d6692 -r 0993af40f8e2 src/errors.c
--- a/src/errors.c      Sun Aug 13 18:21:07 2006
+++ b/src/errors.c      Mon Aug 14 20:29:25 2006
@@ -45,7 +45,8 @@
     /* E_UNIMPLEM  26 */ "* Libkarma warning: Unimplemented call",
     /* E_MFINDERR  27 */ "* Libkarma warning: mount search error",
     /* E_NOMOUNT   28 */ "* Libkarma warning: no mountpoint found",
-    /* E_MANYMOUNT 29 */ "* Libkarma warning: more than one mountpoints"
+    /* E_MANYMOUNT 29 */ "* Libkarma warning: more than one mountpoints",
+    /* E_DUPE      30 */ "* Libkarma warning: file already present"
 };
 
 #define libkarmaErrorString lkerrorList[libkarmaError]
diff -r 2991132d6692 -r 0993af40f8e2 src/lkarma.h
--- a/src/lkarma.h      Sun Aug 13 18:21:07 2006
+++ b/src/lkarma.h      Mon Aug 14 20:29:25 2006
@@ -139,7 +139,9 @@
 #define E_NOMOUNT   28  /* warning: no mountpoints found      */  /* MFIND */
 #define E_MANYMOUNT 29  /* warning: more than 1 mountpoints   */  /* MFIND */
 
-#define MAXLKERRORS 29
+#define E_DUPE      30  /* warning: duplicated file           */
+
+#define MAXLKERRORS 30
 
 
 /*
@@ -174,6 +176,7 @@
 int lk_rio_read(int rio, uint32_t fid, const char * filename);
 int lk_synchronize_necessary(int rio);
 uint32_t lk_rio_write(int rio, const char * filename);
+void lk_karma_write_dupes(int set);
 
 
 /*
diff -r 2991132d6692 -r 0993af40f8e2 src/rio_rw.c
--- a/src/rio_rw.c      Sun Aug 13 18:21:07 2006
+++ b/src/rio_rw.c      Mon Aug 14 20:29:25 2006
@@ -35,6 +35,8 @@
 
 enum { TYPE_DATA, TYPE_MP3, TYPE_OGG, TYPE_FLAC, TYPE_WAV, TYPE_WMA };
 
+static int write_dupes = 0;
+
 static void add_general(HASH * p, const char *filename);
 static int get_ogg_props(HASH *p, const char *filename);
 static int get_flac_props(HASH *p, const char *filename);
@@ -158,12 +160,14 @@
     rid = (char*)lk_generate_rid(rid_fd, mp3.offset, mp3.datasize);
     close(rid_fd);
 
-    fids = lk_properties_andOrSearch(EXACT|ORS, NULL, "rid", rid);
-
-    if (fids != NULL) {
-        free(fids);
-        printf("File already present. Skipping...\n");
-        return -1;
+    if (write_dupes == 0) {
+        fids = lk_properties_andOrSearch(EXACT|ORS, NULL, "rid", rid);
+
+        if (fids != NULL) {
+            free(fids);
+            lk_errors_set(E_DUPE);
+            return -1;
+        }
     }
 
     new_fid=lk_properties_new_property(); 
@@ -476,3 +480,9 @@
 
     return type;
 }
+
+void lk_karma_write_dupes(int set)
+{
+    write_dupes = set;
+}
+
diff -r 2991132d6692 -r 0993af40f8e2 tools/riocp.c
--- a/tools/riocp.c     Sun Aug 13 18:21:07 2006
+++ b/tools/riocp.c     Mon Aug 14 20:29:25 2006
@@ -57,7 +57,7 @@
                         "[-s searchString ]\n"
            "             [-u props] [-x props] [-l props] "
                         "[-c charSet] [-e set1 set2 set3]\n"
-           "             [-D dummyName] [-q] [-d] [-r] [-R] [-b] [-w]\n" 
+           "             [-D dummyName] [-q] [-d] [-r] [-R] [-b] [-w] [-f]\n" 
            "             [files_to_upload ...]\n"
            "\n");
     if(!complete) return;
@@ -96,6 +96,7 @@
            "  \"-R\" same as -r, but do not ask for confirmation\n");
     printf("  \"-b\" get database by scanning *1 files, instead of smalldb\n");
     printf("  \"-w\" don't rewrite the smalldb database file\n");
+    printf("  \"-f\" force the files to be written even if they are dupes\n");
 }
 
 void currentKarma(int i, int *k) 
@@ -111,7 +112,7 @@
 {
     static int first = 1;
     static int karma;
-    uint32_t fid;
+    int fid;
 
     if(first){   
         currentKarma(0, &karma);
@@ -383,7 +384,7 @@
     char *utf;
     char *device=NULL;
     
-    while ((c = getopt(argc, argv, "dhqrRbwa:c:e:p:s:S:u:x:l:D:")) != -1) {
+    while ((c = getopt(argc, argv, "dhqrRbwfa:c:e:p:s:S:u:x:l:D:")) != -1) {
         switch(c) {
             case 'h': case '?':
                 usage(1);
@@ -403,6 +404,9 @@
                 break;
             case 'w':
                 writeSmalldb=0;
+                break;
+            case 'f':
+                lk_karma_write_dupes(1);
                 break;
             case 'a':
                 host=strdup(optarg);
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
linux-karma-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-karma-devel

Reply via email to