2006-08-14: EV dixit:
> 2006-08-14: EV dixit:
> > 2006-08-14: Keith Bennett dixit:
> > > [...]
> > > This patch fixes the two issues reported.
> >
> > This patch (libkarma-hg96-dupes.patch) is giving me troubles
> > (in rio_rw.c) as it is not fully compatible with your previous
> > tags-libkarma-hg96.patch. If you have a consistent version
> > including both patches, can you please provide just one with
> > all the changes included?
>
> Forget about it. I am now testing and everything seems O.K.
>
> Nevertheless, to avoid possible confussion, Franky, please wait
> for my new patch which will consolidated the previous two from
> Keith and will remove the printf's from rio_rw.c.
The attached patch is against changeset 97, which is tobe
obtained by aplying Keith's tags-libkarma-hg96.patch to the
current repository tip, changeset 96.
Apart from the error handling, I've fixed some rather minor
issues mostly related with missing properties/tags.
Best,
EV.
# HG changeset patch
# User [EMAIL PROTECTED]
# Node ID b3dfda9778d161d7124d266798d7b9cd40aef833
# Parent 9fc39d247b7681c3a562d38170930a6f58379d6f
Make dupe skipping optional. Fixed rio_rw error handling and several other
minor bugs
diff -r 9fc39d247b76 -r b3dfda9778d1 src/errors.c
--- a/src/errors.c Mon Aug 14 21:45:11 2006
+++ b/src/errors.c Tue Aug 15 12:47:02 2006
@@ -36,16 +36,21 @@
/* E_SSDPPARSE 17 */ "* Libkarma warning: ssdp parsing failed",
/* E_MKDIR 18 */ "** Libkarma error: mkdir() failed",
/* E_UTIME 19 */ "** Libkarma error: utime() failed",
- /* E_NODIR 20 */ "** Libkarma error: Unexisting directory",
- /* E_NOPROP 21 */ "* Libkarma warning: Missing fid properties",
- /* E_READ 22 */ "* Libkarma warning: Read error",
- /* E_WRITE 23 */ "** Libkarma error: Write error",
- /* E_DELETE 24 */ "** Libkarma error: Delete error",
- /* E_NODEVSET 25 */ "* Libkarma warning: No device-settings file",
- /* E_UNIMPLEM 26 */ "* Libkarma warning: Unimplemented call",
+ /* E_NODIR 20 */ "** Libkarma error: unexisting directory",
+ /* E_NOPROP 21 */ "* Libkarma warning: missing fid properties",
+ /* E_READ 22 */ "* Libkarma warning: read error",
+ /* E_WRITE 23 */ "** Libkarma error: write error",
+ /* E_DELETE 24 */ "** Libkarma error: delete error",
+ /* E_NODEVSET 25 */ "* Libkarma warning: no device-settings file",
+ /* 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: tune already present",
+ /* E_PATHCREAT 31 */ "* Libkarma warning: dir access/create failed",
+ /* E_NOHASH 32 */ "** Libkarma error: no hash found",
+ /* E_WRCHUNK 33 */ "** Libkarma error: write_file_chunk() failed",
+ /* E_SMALLMP3 34 */ "** Libkarma error: tune file is too small"
};
#define libkarmaErrorString lkerrorList[libkarmaError]
diff -r 9fc39d247b76 -r b3dfda9778d1 src/lkarma.h
--- a/src/lkarma.h Mon Aug 14 21:45:11 2006
+++ b/src/lkarma.h Tue Aug 15 12:47:02 2006
@@ -127,19 +127,25 @@
#define E_MKDIR 18 /* error: mkdir() failed */ /* Sys */
#define E_UTIME 19 /* error: utime() failed */ /* Sys */
-#define E_NODIR 20 /* error: Unexisting directory */ /* USB */
-#define E_NOPROP 21 /* warning: Missing prop file */ /* USB */
-#define E_READ 22 /* error: Read error */ /* USB */
-#define E_WRITE 23 /* error: Write error */ /* USB */
-#define E_DELETE 24 /* warning: Delete error */ /* USB */
-#define E_NODEVSET 25 /* warning: No device-settings file */ /* USB */
-#define E_UNIMPLEM 26 /* warning: Unimplemented call */ /* USB */
+#define E_NODIR 20 /* error: unexisting directory */ /* USB */
+#define E_NOPROP 21 /* warning: missing prop file */ /* USB */
+#define E_READ 22 /* error: read error */ /* USB */
+#define E_WRITE 23 /* error: write error */ /* USB */
+#define E_DELETE 24 /* warning: delete error */ /* USB */
+#define E_NODEVSET 25 /* warning: no device-settings file */ /* USB */
+#define E_UNIMPLEM 26 /* warning: unimplemented call */ /* USB */
#define E_MFINDERR 27 /* warning: mount search error */ /* MFIND */
#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: file already present */ /* RIO_RW */
+#define E_PATHCREAT 31 /* warning: dir access/create failed */ /* RIO_RW */
+#define E_NOHASH 32 /* error: no hash found */ /* RIO_RW */
+#define E_WRCHUNK 33 /* error: write_file_chunk() failed */ /* RIO_RW */
+#define E_SMALLMP3 34 /* error: tune file is too small */ /* RIO_RW */
+
+#define MAXLKERRORS 34
/*
@@ -169,11 +175,13 @@
/*
* rio_rw
*/
+#define MODE_PROPERTY "play_count_limit" /* for taxi files chmod in lkarmafs
*/
int lk_rio_read_playlist(int rio, uint32_t fid, const char * filename);
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);
int lk_rio_update_props_from_tags(int rio, uint32_t fid, const char *fname);
diff -r 9fc39d247b76 -r b3dfda9778d1 src/rio_rw.c
--- a/src/rio_rw.c Mon Aug 14 21:45:11 2006
+++ b/src/rio_rw.c Tue Aug 15 12:47:02 2006
@@ -32,9 +32,12 @@
/* #define BLOCKSIZE 32768 */
#define BLOCKSIZE 131072
-#define NOT_TAGGED "[karmalib 0.4]"
+/* #define NOT_TAGGED "[karmalib 0.4]" */
+#define NOT_TAGGED "unTagged" /* something more explicit and readable ... */
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);
@@ -72,9 +75,10 @@
if (pl==NULL)
return -1; /* Can't get playlist for this fid */
- if (mk_path(filename))
- fprintf(stderr,
- "** Could not create directory of path: %s\n", filename);
+ if (mk_path(filename)) {
+ lk_errors_set(E_PATHCREAT);
+/* fprintf(stderr,"** Error creating directory of path: %s\n",filename);
*/
+ }
dst=open(filename,
O_CREAT|O_EXCL|O_WRONLY,S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
if(dst==-1)
@@ -94,9 +98,10 @@
char *tmp, *tmp1;
/* dst=creat(filename, O_EXCL); */
- if (mk_path(filename))
- fprintf(stderr,
- "** Could not create directory of path: %s\n", filename);
+ if (mk_path(filename)) {
+ lk_errors_set(E_PATHCREAT);
+/* fprintf(stderr,"** Error creating directory of path: %s\n",filename);
*/
+ }
dst=open(filename,
O_CREAT|O_EXCL|O_WRONLY,S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
if(dst==-1)
@@ -141,7 +146,7 @@
filename = lk_karma_fidToPath(rio, fid);
usb = 1;
} else
- filename = fname;
+ filename = (char *)fname;
if(lstat(filename, &len)==-1) {
if (usb) {
@@ -159,16 +164,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) {
- if (usb) {
- unlink(filename);
- free(filename);
- }
- 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;
+ }
}
/* uses lk_properties_getnextfid()...*/
@@ -178,7 +181,8 @@
unlink(filename);
free(filename);
}
- printf("huh, no hash found?\n");
+ lk_errors_set(E_NOHASH);
+/* printf("huh, no hash found?\n"); */
return -1;
}
@@ -246,7 +250,8 @@
fid, 0, tmp) != 0)
*/
if(lk_karma_write_file_chunk(rio, offs, got, fid, 0, tmp)!=0) {
- printf("lk_karma_write_file_chunk: %u of %llu\n", got, siz);
+ lk_errors_set(E_WRCHUNK);
+/* printf("lk_karma_write_file_chunk: %u of %llu\n", got, siz); */
lk_properties_del_property(fid);
return -1;
}
@@ -284,8 +289,13 @@
static int get_ogg_props(HASH *p, const char *filename)
{
+ lk_properties_set_property_hash(p, "type", "tune");
lk_properties_set_property_hash(p, "codec", "vorbis");
- lk_properties_set_property_hash(p, "type", "tune");
+
+ /*default values*/
+ lk_properties_set_property_hash(p, "genre", NOT_TAGGED);
+ lk_properties_set_property_hash(p, "artist", NOT_TAGGED);
+ lk_properties_set_property_hash(p, "source", NOT_TAGGED);
set_tag_props(p, filename, TagLib_File_OggVorbis);
return 0;
@@ -293,13 +303,17 @@
static int get_flac_props(HASH *p, const char *filename)
{
+ lk_properties_set_property_hash(p, "type", "tune");
+ lk_properties_set_property_hash(p, "codec", "flac");
+
/*default values*/
+ lk_properties_set_property_hash(p, "genre", NOT_TAGGED);
+ lk_properties_set_property_hash(p, "artist", NOT_TAGGED);
lk_properties_set_property_hash(p, "source", NOT_TAGGED);
- lk_properties_set_property_hash(p, "artist", NOT_TAGGED);
-
- lk_properties_set_property_hash(p, "codec", "flac");
- lk_properties_set_property_hash(p, "type", "tune");
-
+
+#ifndef TagLib_File_FLAC /* older tag_c libs don't have TagLib_File_FLAC */
+#define TagLib_File_FLAC -1
+#endif
set_tag_props(p, filename, TagLib_File_FLAC);
return 0;
}
@@ -310,7 +324,9 @@
lk_properties_set_property_hash(p, "type", "tune");
lk_properties_set_property_hash(p, "codec", "mp3");
+
/*default values*/
+ lk_properties_set_property_hash(p, "genre", NOT_TAGGED);
lk_properties_set_property_hash(p, "artist", NOT_TAGGED);
lk_properties_set_property_hash(p, "source", NOT_TAGGED);
@@ -329,10 +345,11 @@
{
lk_properties_set_property_hash(p, "duration", "0");
lk_properties_set_property_hash(p, "offset", "0");
- lk_properties_set_property_hash(p, "bitrate", "fs128");
+/* lk_properties_set_property_hash(p, "bitrate", "fs128"); */ /* unneeded */
lk_properties_set_property_hash(p, "codec", "taxi");
lk_properties_set_property_hash(p, "type", "taxi");
-
+ /* Set read-only access permissions for lkarmafs */
+ lk_properties_set_property_hash(p, MODE_PROPERTY, "33060");
return 0;
}
/*
@@ -352,8 +369,9 @@
lk_properties_set_property_hash(p, "codec", "wave");
lk_properties_set_property_hash(p, "type", "tune");
lk_properties_set_property_hash(p, "bitrate", "fs999");
+ lk_properties_set_property_hash(p, "genre", NOT_TAGGED);
+ lk_properties_set_property_hash(p, "artist", "wave_file");
lk_properties_set_property_hash(p, "source", "wave_file");
- lk_properties_set_property_hash(p, "artist", "wave_file");
lk_properties_set_property_hash(p, "samplerate",
simple_itoa(wh->nSamplesPerSec));
lk_properties_set_property_hash(p, "duration", simple_itoa(1000 *
@@ -384,6 +402,10 @@
int i;
char bitrate[6];
+ if(type != -1)
+ tl_file = taglib_file_new_type(filename, type);
+ else
+ tl_file = taglib_file_new(filename);
tl_file = taglib_file_new_type(filename, type);
tl_tag = taglib_file_tag(tl_file);
tl_audio = taglib_file_audioproperties(tl_file);
@@ -440,8 +462,8 @@
if (mp3->datasize >= 128) {
if (fseek(mp3->file, -128, SEEK_END )) {
- fprintf(stderr, "ERROR: Couldn't read last 128 bytes of %s.\n",
- mp3->filename);
+ lk_errors_set(E_SMALLMP3);
+/* fprintf(stderr,"read err: last 128 bytes of
%s.\n",mp3->filename);*/
return -1;
} else {
fread(buf, 1, 3, mp3->file);
@@ -515,3 +537,9 @@
return type;
}
+
+void lk_karma_write_dupes(int set)
+{
+ write_dupes = set;
+}
+
diff -r 9fc39d247b76 -r b3dfda9778d1 tools/riocp.c
--- a/tools/riocp.c Mon Aug 14 21:45:11 2006
+++ b/tools/riocp.c Tue Aug 15 12:47:02 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