Hi,

The attached patch makes a few bugfixes for fdb support.

On Sat, Aug 19, 2006, EV wrote:
> I've tested and looks like something has got broken :(  The
> observed bugs are not consistent (not always the same); so it
> might be a side effect from some memory problem...
> 
> A few of the errors I've got:
> 
> - Using Ethernet, riocp (without arguments) systematically gives:
>   * Libkarma warning: missing fid properties
>   ** Libkarma error: broken Rio header
>   ** Libkarma error: broken Rio header
>   ** Libkarma error: write_file_chunk() failed

I think that this might be fixed now, but I can't test it.

> - Both USB/Ethernet: "./riocp -s title=fdb" find nothing and
>   gives "* Libkarma warning: missing fid properties".  This has
>   happened exactly 50% of the times I've tried.  The times it
>   succeeds you also get a (different) error:  "* Libkarma
>   warning: tune already present"

This seems to be a regression to my own tree. I had fixed this bug
before and it somehow seems to have crept back in.
Fixed now, I think.

> Another point:  The name 'fdb.gz' is too common.  I'd rather use 
> something more specific such as 'libkarma_path_db.gz', mainly in 
> the RK taxi "directory".

Done.

Keith.
# HG changeset patch
# User Keith Bennett <[EMAIL PROTECTED]>
# Node ID 14deb6994f5e111c836d0b530b139c001d88cad1
# Parent  31d58457fe4f8dd522e969c1106f51289df89563
Bugfixes for fdb support.

diff -r 31d58457fe4f -r 14deb6994f5e src/fdb.c
--- a/src/fdb.c Sat Aug 19 17:10:17 2006
+++ b/src/fdb.c Sun Aug 20 17:07:12 2006
@@ -16,6 +16,8 @@
 #include "util.h"
 #include "rio_rw.h"
 #include "fdb.h"
+
+#define FDB_FILENAME "__libkarma_fdb__.gz"
 
 static int rio = 0;
 
@@ -37,11 +39,11 @@
     /*
      * Datenbank vom Karma laden
     */
-    fname=lk_path_string("fdb.gz");
+    fname=lk_path_string(FDB_FILENAME);
     if (fname == NULL)
         return -1;
 
-    db=lk_properties_andOrSearch(EXACT|ORS, NULL, "title", "fdb.gz");
+    db=lk_properties_andOrSearch(EXACT|ORS, NULL, "title", FDB_FILENAME);
     if (db) {
         db=lk_properties_andOrSearch(EXACT|ORS, db, "type", "taxi");
         if (db) {
@@ -138,31 +140,32 @@
     gzFile fdb_file;
     char * fname;
     char * id, * path, * tm;
-    uint32_t * fdb, *db;
+    uint32_t * fdb;
     HASH * tmp;
     int i=0, first=1;
     
-    fname=lk_path_string("fdb.gz");
+    fname=lk_path_string(FDB_FILENAME);
+    fdb_file=gzopen(fname, "w");
+    if (fdb_file == NULL)
+        return NULL;
+
     fdb=lk_properties_andOrSearch(EXACT|ORS, NULL, "path", "");
     if(fdb){
-        fdb_file=gzopen(fname, "w");
         for(i=0; fdb[i]; i++){
             tmp=lk_properties_idsearch(fdb[i]);
             if (!tmp)
                 continue;
             path=lk_properties_get_property_hash(tmp, "path");
             tm=lk_properties_get_property_hash(tmp, "fid_generation");
+
             if (!path || !tm) {
                 if (first) {
-                    db=lk_properties_andOrSearch(EXACT|ORS, NULL, "title",
-                                                                  "fdb.gz");
-                    if (db) {
-                        db=lk_properties_andOrSearch(EXACT|ORS, db, "type",
-                                                                    "taxi");
-                        if (db) {
-                            free(db);
+                    tm=lk_properties_get_property_hash(tmp, "title");
+                    if (tm && strncmp(tm, FDB_FILENAME,
+                                      strlen(FDB_FILENAME)+1) == 0) {
+                        tm =lk_properties_get_property_hash(tmp, "type");
+                        if (tm && strncmp(tm, "taxi", 5) == 0)
                             continue;
-                        }
                     }
                     lk_errors_set(E_NOPROP);
                     first = 0;
@@ -176,12 +179,11 @@
             gzwrite(fdb_file, " ", 1);
             gzwrite(fdb_file, path, strlen(path));
             gzwrite(fdb_file, "\n", 1);
-            
         }
         free(fdb);
         gzclose(fdb_file);
     }
-    lk_rio_write_fdb(fname);
+    lk_rio_write_fdb(rio, fname);
 
     /*
      * Datenbank auf Karma als Taxifile kopieren...
diff -r 31d58457fe4f -r 14deb6994f5e src/karma.c
--- a/src/karma.c       Sat Aug 19 17:10:17 2006
+++ b/src/karma.c       Sun Aug 20 17:07:12 2006
@@ -245,6 +245,7 @@
 void lk_karma_load_database(int rio)
 {
     lk_ops->lk_karma_load_database(rio);
+    lk_fdb_load();
 }
 
 void lk_karma_update_database(int rio)
diff -r 31d58457fe4f -r 14deb6994f5e src/karmaUsb.c
--- a/src/karmaUsb.c    Sat Aug 19 17:10:17 2006
+++ b/src/karmaUsb.c    Sun Aug 20 17:07:12 2006
@@ -22,6 +22,7 @@
 #include <sys/vfs.h>            /* or <sys/statfs.h> */
 #include <sys/types.h>
 #include <unistd.h>
+#include <utime.h>
 
 #include "lkarma.h"
 #include "karmaUsb.h"
@@ -63,12 +64,29 @@
 /* ******************** Implemented OMFS mount here ?? ********************** 
*/
 /* The path must be absolute to be accesible in lkarmafs;  e.g.: /mnt/karma2/ 
*/
     int len = strlen(path);
+    char *fname, *settings;
+    struct utimbuf time;
+    int ret = 0;
 
     usbMountPoint = malloc(len + 2);
     strcpy(usbMountPoint, path);
     if(path[len - 1] != '/')
         strcat(usbMountPoint, "/");
-    return lk_is_karma_mountpoint(usbMountPoint);
+    ret = lk_is_karma_mountpoint(usbMountPoint);
+    if (ret)
+        return ret;
+
+    lk_karmaUsb_get_device_settings(0, &settings);
+    lk_properties_import(settings);
+    free(settings);
+
+    time.modtime=0;
+    fname=lk_path_string("fileinfo");
+    if(utime(fname, &time)==-1){
+        free(fname);
+        lk_errors_set(E_UTIME);
+    }
+    return ret;
 }
 
 /* -------------------------------------------------------------------------- 
*/
diff -r 31d58457fe4f -r 14deb6994f5e src/properties.c
--- a/src/properties.c  Sat Aug 19 17:10:17 2006
+++ b/src/properties.c  Sun Aug 20 17:07:12 2006
@@ -132,7 +132,6 @@
         }
     }
     hash_destroy(&item);
-    lk_fdb_load();
     return count;
 }
 
@@ -285,7 +284,6 @@
     lk_properties_import(buf);
     free(buf);
     free(fname);
-    lk_fdb_load();
     return 0;
 }
 /*
diff -r 31d58457fe4f -r 14deb6994f5e src/rio_rw.c
--- a/src/rio_rw.c      Sat Aug 19 17:10:17 2006
+++ b/src/rio_rw.c      Sun Aug 20 17:07:12 2006
@@ -133,7 +133,8 @@
     return 0;
 }
 
-int lk_rio_update_props_from_tags(int rio, uint32_t fid, const char *fname)
+static int lk_rio_do_update_props_from_tags(int fdb, int rio, uint32_t fid,
+                                            const char *fname)
 {
     int got=-1, usb=0;
     char *rid, *filename;
@@ -165,7 +166,7 @@
     rid = (char*)lk_generate_rid(rid_fd, mp3.offset, mp3.datasize);
     close(rid_fd);
 
-    if (write_dupes == 0) {
+    if (write_dupes == 0 && fdb == 0) {
         fids = lk_properties_andOrSearch(EXACT|ORS, NULL, "rid", rid);
 
         if (fids != NULL) {
@@ -215,6 +216,11 @@
     return got;
 }
 
+int lk_rio_update_props_from_tags(int rio, uint32_t fid, const char *fname)
+{
+    return lk_rio_do_update_props_from_tags(0, rio, fid, fname);
+}
+
 /*
      To use that function properly:
          1. Get an IO Lock for Writing
@@ -250,7 +256,7 @@
     if (!fid)
         fid = lk_properties_new_property(); 
 
-    got = lk_rio_update_props_from_tags(rio, fid, filename);
+    got = lk_rio_do_update_props_from_tags(fdb, rio, fid, filename);
     if (got != 0)
         lk_properties_del_property(fid);
 
@@ -293,9 +299,9 @@
     return lk_rio_do_write(0, rio, filename);
 }
 
-uint32_t lk_rio_write_fdb(const char * filename)
-{
-    return lk_rio_do_write(1, 0, filename);
+uint32_t lk_rio_write_fdb(int rio, const char * filename)
+{
+    return lk_rio_do_write(1, rio, filename);
 }
 
 static void add_general(HASH * p, const char *filename)
diff -r 31d58457fe4f -r 14deb6994f5e src/rio_rw.h
--- a/src/rio_rw.h      Sat Aug 19 17:10:17 2006
+++ b/src/rio_rw.h      Sun Aug 20 17:07:12 2006
@@ -13,6 +13,6 @@
 
 #include "lkarma.h"
 
-uint32_t lk_rio_write_fdb(const char * filename);
+uint32_t lk_rio_write_fdb(int rio, const char * filename);
 
 #endif /* _RIO_RW_H */
-------------------------------------------------------------------------
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