Skip to content

Commit

Permalink
if the same release is uploaded to the same place >1 times, no announ…
Browse files Browse the repository at this point in the history
…ce will happen in glftpd.log. Please note that this change require a rm -fR ftp-data/pzs-ng/*
  • Loading branch information
psxc committed Feb 8, 2007
1 parent 63e968c commit c986e80
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 26 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ v1.0.7 --> 1.0.X :
- fix a bug in rescan when scanning new (not previously scanned) dirs.
- fix a bug with rescan in 'quick' mode.
- added '2007' and removed '2003' from list of allowed years in mp3.
- on mp3 group-sort internal releases will not be renamed - only the
groupdir will.
- the zipscript will no longer announce a release twice - dupe uploads
will be marked correctly, but no announce will happen in glftpd.log.
v1.0.6 --> 1.0.7 : (r2230)
- updated libcopy to v1.2 - fix for openbsd4.0.
- added support for not sorting audio in certain dirs.
Expand Down
2 changes: 1 addition & 1 deletion UPDATING
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ zsconfig.h: The option 'del_progressmeter' has changed. Make sure you have
Changed in: r1348

racedata changed. You *HAVE* *TO* rm -fR ftp-data/pzs-ng/*.
Changed in: 1277, 1458, 1474, 1508, 1521, 1535
Changed in: 1277, 1458, 1474, 1508, 1521, 1535, 2246


dZSbot.conf A dZSbot.conf.defaults first appeared in r1120 - if your bot
Expand Down
3 changes: 2 additions & 1 deletion zipscript/include/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ struct misc {
unsigned char write_log;
long fastest_user[2];
long slowest_user[2];
unsigned int data_completed;
};

struct VARS {
Expand Down Expand Up @@ -187,6 +188,6 @@ typedef struct {
/* sfv_version - must be > 5. Should not be any need to add a version
* for racedata - if either sfv_data or racedata changes, they both
* should be removed */
#define sfv_version 16
#define sfv_version 17

#endif
15 changes: 8 additions & 7 deletions zipscript/include/race-file.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ typedef struct {

/* this is what we put in a special 'head' file for version control, lock etc */
typedef struct {
unsigned int data_version; // version control.
unsigned int data_type; // type of release.
unsigned int data_in_use; // which program currently holds the lock.
unsigned int data_incrementor; // a check to see if nothing else wants the lock.
unsigned int data_queue; // positions in queue.
unsigned int data_qcurrent; // current position in queue.
unsigned int data_pid; // the pid of the process holding the lock.
unsigned int data_version, // version control.
data_type, // type of release.
data_in_use, // which program currently holds the lock.
data_incrementor, // a check to see if nothing else wants the lock.
data_queue, // positions in queue.
data_qcurrent, // current position in queue.
data_pid, // the pid of the process holding the lock.
data_completed; // flag to mark release as complete.
} HEADDATA;

extern unsigned int readsfv(const char *, struct VARS *, int);
Expand Down
4 changes: 2 additions & 2 deletions zipscript/src/audiosort.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void audioSort(struct audio *info, char *link_source, char *link_target)
#if ( audio_genre_sort == TRUE ) || (audio_artist_sort == TRUE) || (audio_year_sort == TRUE) || (audio_group_sort == TRUE) || (audio_language_sort == TRUE)
char *temp_p = NULL;
char *temp_q = NULL;
char temp_nam[NAME_MAX];
char temp_nam[16];
int n = 0;
#if (audio_language_sort == TRUE)
char language[3];
Expand Down Expand Up @@ -117,9 +117,9 @@ if (subcomp(link_target, NULL)) {
d_log("audioSort: Sorting mp3 by group\n");
temp_p = remove_pattern(link_target, "*-", RP_LONG_LEFT);
temp_p = remove_pattern(temp_p, "_", RP_SHORT_LEFT);
strncpy(temp_nam, temp_p, sizeof(temp_nam));
n = (int)strlen(temp_p);
if (n > 0 && n < 15) {
strncpy(temp_nam, temp_p, sizeof(temp_nam));
if (n > 4) {
temp_q = temp_nam + n - 4;
if (!strncasecmp(temp_q, "_INT", 4)) {
Expand Down
8 changes: 8 additions & 0 deletions zipscript/src/race-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,7 @@ create_lock(struct VARS *raceI, const char *path, unsigned int progtype, unsigne
raceI->data_incrementor = hd.data_incrementor = 1;
raceI->data_queue = hd.data_queue = 1;
hd.data_qcurrent = 0;
raceI->misc.data_completed = hd.data_completed = 0;
hd.data_pid = (unsigned int)getpid();
if (write(fd, &hd, sizeof(HEADDATA)) != sizeof(HEADDATA))
d_log("create_lock: write failed: %s\n", strerror(errno));
Expand All @@ -976,6 +977,7 @@ create_lock(struct VARS *raceI, const char *path, unsigned int progtype, unsigne
raceI->data_incrementor = hd.data_incrementor = 1;
raceI->data_queue = hd.data_queue = 1;
hd.data_qcurrent = 0;
raceI->misc.data_completed = hd.data_completed;
hd.data_pid = (unsigned int)getpid();
lseek(fd, 0L, SEEK_SET);
if (write(fd, &hd, sizeof(HEADDATA)) != sizeof(HEADDATA))
Expand All @@ -999,6 +1001,7 @@ create_lock(struct VARS *raceI, const char *path, unsigned int progtype, unsigne
d_log("create_lock: lock active - putting you in queue. (%d/%d)\n", hd.data_qcurrent, hd.data_queue);
}
raceI->misc.release_type = hd.data_type;
raceI->misc.data_completed = hd.data_completed;
close(fd);
return hd.data_in_use;
}
Expand All @@ -1015,6 +1018,7 @@ create_lock(struct VARS *raceI, const char *path, unsigned int progtype, unsigne
hd.data_queue++; /* we increment the number in the queue */
raceI->data_incrementor = hd.data_incrementor;
raceI->misc.release_type = hd.data_type;
raceI->misc.data_completed = hd.data_completed;
lseek(fd, 0L, SEEK_SET);
if (write(fd, &hd, sizeof(HEADDATA)) != sizeof(HEADDATA))
d_log("create_lock: write failed: %s\n", strerror(errno));
Expand All @@ -1027,6 +1031,7 @@ create_lock(struct VARS *raceI, const char *path, unsigned int progtype, unsigne
/* the queue is still less than current. */
raceI->data_incrementor = hd.data_incrementor; /* feed back the current incrementor */
raceI->misc.release_type = hd.data_type;
raceI->misc.data_completed = hd.data_completed;
close(fd);
unlink(lockfile);
return -1;
Expand All @@ -1040,6 +1045,7 @@ create_lock(struct VARS *raceI, const char *path, unsigned int progtype, unsigne
hd.data_in_use = progtype;
}
raceI->data_incrementor = hd.data_incrementor;
raceI->misc.data_completed = hd.data_completed;
raceI->misc.release_type = hd.data_type;
hd.data_pid = (unsigned int)getpid();
lseek(fd, 0L, SEEK_SET);
Expand Down Expand Up @@ -1072,6 +1078,7 @@ remove_lock(struct VARS *raceI)
read(fd, &hd, sizeof(HEADDATA));
hd.data_in_use = 0;
hd.data_pid = 0;
hd.data_completed = raceI->misc.data_completed;
hd.data_incrementor = 0;
if (hd.data_queue) /* if queue, increase the number in current so the next */
hd.data_qcurrent++; /* process can start. */
Expand Down Expand Up @@ -1142,6 +1149,7 @@ update_lock(struct VARS *raceI, unsigned int counter, unsigned int datatype)
retval = hd.data_incrementor;
}
raceI->misc.release_type = hd.data_type;
raceI->misc.data_completed = hd.data_completed;
if (hd.data_pid != (unsigned int)getpid() && hd.data_incrementor) {
d_log("update_lock: Oops! Race condition - another process has the lock. pid: %d != %d\n", hd.data_pid, (unsigned int)getpid());
hd.data_queue = raceI->data_queue - 1;
Expand Down
41 changes: 32 additions & 9 deletions zipscript/src/zipscript-c.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ main(int argc, char **argv)
char *race_halfway_type = 0;
char *norace_halfway_type = 0;
char *inc_point[2];
unsigned int release_completed = 0;
#ifdef _WITH_SS5
unsigned char complete_type = 1;
#else
Expand Down Expand Up @@ -761,8 +762,12 @@ main(int argc, char **argv)
g.v.misc.write_log = matchpath(sfv_dirs, g.l.path);
if (g.v.total.files_missing > 0) {
if (sfv_msg != NULL) {
d_log("zipscript-c: Writing SFV message to %s\n", log);
writelog(&g, convert(&g.v, g.ui, g.gi, sfv_msg), sfv_type);
if (g.v.misc.data_completed)
d_log("zipscript-c: This release has previously been announced complete - skipping announce\n");
else {
d_log("zipscript-c: Writing SFV message to %s\n", log);
writelog(&g, convert(&g.v, g.ui, g.gi, sfv_msg), sfv_type);
}
}
} else {
if (g.v.misc.release_type == RTYPE_AUDIO) {
Expand Down Expand Up @@ -1264,7 +1269,10 @@ main(int argc, char **argv)
if (!race_type)
d_log("zipscript-c: Something's messed up - race_type not set!\n");

writelog(&g, convert(&g.v, g.ui, g.gi, race_msg), race_type);
if (g.v.misc.data_completed)
d_log("zipscript-c: This release has previously been announced complete - skipping announce\n");
else
writelog(&g, convert(&g.v, g.ui, g.gi, race_msg), race_type);
}

/*
Expand Down Expand Up @@ -1300,7 +1308,10 @@ main(int argc, char **argv)
if (!newleader_type)
d_log("zipscript-c: Something's messed up - newleader_type not set!\n");

writelog(&g, convert(&g.v, g.ui, g.gi, newleader_msg), newleader_type);
if (g.v.misc.data_completed)
d_log("zipscript-c: This release has previously been announced complete - skipping announce\n");
else
writelog(&g, convert(&g.v, g.ui, g.gi, newleader_msg), newleader_type);
}
} else {

Expand Down Expand Up @@ -1335,7 +1346,10 @@ main(int argc, char **argv)
if (!update_type)
d_log("zipscript-c: Something's messed up - update_type not set!\n");

writelog(&g, convert(&g.v, g.ui, g.gi, update_msg), update_type);
if (g.v.misc.data_completed)
d_log("zipscript-c: This release has previously been announced complete - skipping announce\n");
else
writelog(&g, convert(&g.v, g.ui, g.gi, update_msg), update_type);
}
}
}
Expand Down Expand Up @@ -1378,7 +1392,10 @@ main(int argc, char **argv)
if (!race_halfway_type)
d_log("zipscript-c: Something's messed up - race_halfway_type not set!\n");

writelog(&g, convert(&g.v, g.ui, g.gi, halfway_msg), (g.v.total.users > 1 ? race_halfway_type : norace_halfway_type));
if (g.v.misc.data_completed)
d_log("zipscript-c: This release has previously been announced complete - skipping announce\n");
else
writelog(&g, convert(&g.v, g.ui, g.gi, halfway_msg), (g.v.total.users > 1 ? race_halfway_type : norace_halfway_type));
}
/*
* It is _very_ unlikely that halfway would be
Expand Down Expand Up @@ -1473,9 +1490,14 @@ main(int argc, char **argv)
//complete(&g.l, &g.v, g.ui, g.gi, complete_type);

if (complete_msg != NULL) {
d_log("zipscript-c: Writing COMPLETE and STATS to %s\n", log);
writelog(&g, convert(&g.v, g.ui, g.gi, complete_msg), complete_announce);
writetop(&g, complete_type);
if (g.v.misc.data_completed)
d_log("zipscript-c: This release has previously been announced complete - skipping announce\n");
else {
d_log("zipscript-c: Writing COMPLETE and STATS to %s\n", log);
writelog(&g, convert(&g.v, g.ui, g.gi, complete_msg), complete_announce);
writetop(&g, complete_type);
g.v.misc.data_completed = 1;
}
}
if (complete_bar) {
d_log("zipscript-c: Creating complete bar\n");
Expand Down Expand Up @@ -1627,3 +1649,4 @@ main(int argc, char **argv)
d_log("zipscript-c: Exit %d\n", exit_value);
return exit_value;
}

13 changes: 7 additions & 6 deletions zipscript/utils/headdatatest.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ int main(int argc, char **argv)


fread(&sd, sizeof(HEADDATA), 1, f);
printf("data version: %d\n", sd.data_version);
printf("release type: %d\n", sd.data_type);
printf("locked : %d\n", sd.data_in_use);
printf("data inc. : %d\n", sd.data_incrementor);
printf("queue : %d/%d\n", sd.data_qcurrent, sd.data_queue);
printf("process pid : %d\n", sd.data_pid);
printf("data version : %d\n", sd.data_version);
printf("release type : %d\n", sd.data_type);
printf("locked : %d\n", sd.data_in_use);
printf("data inc. : %d\n", sd.data_incrementor);
printf("queue : %d/%d\n", sd.data_qcurrent, sd.data_queue);
printf("process pid : %d\n", sd.data_pid);
printf("completed flag: %d\n", sd.data_completed);

fclose(f);

Expand Down

0 comments on commit c986e80

Please sign in to comment.