mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
Deleted the index_lock() nonsense.
This commit is contained in:
parent
0f328d079c
commit
5a5835b4fa
1 changed files with 2 additions and 30 deletions
32
data.c
32
data.c
|
@ -244,32 +244,11 @@ double mtime_nl(const char *fn, int *n_link)
|
|||
/** indexes **/
|
||||
|
||||
|
||||
FILE *index_lock(const char *fn)
|
||||
{
|
||||
xs *lck = xs_fmt("%s.lck", fn);
|
||||
FILE *f = fopen(lck, "a");
|
||||
flock(fileno(f), LOCK_EX);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
void index_unlock(FILE *f, const char *fn)
|
||||
{
|
||||
xs *lck = xs_fmt("%s.lck", fn);
|
||||
unlink(lck);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
|
||||
int index_add_md5(const char *fn, const char *md5)
|
||||
/* adds an md5 to an index */
|
||||
{
|
||||
int status = 201; /* Created */
|
||||
FILE *l, *f;
|
||||
|
||||
if ((l = index_lock(fn)) == NULL)
|
||||
return 500;
|
||||
FILE *f;
|
||||
|
||||
if ((f = fopen(fn, "a")) != NULL) {
|
||||
flock(fileno(f), LOCK_EX);
|
||||
|
@ -283,8 +262,6 @@ int index_add_md5(const char *fn, const char *md5)
|
|||
else
|
||||
status = 500;
|
||||
|
||||
index_unlock(l, fn);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -301,10 +278,7 @@ int index_del_md5(const char *fn, const char *md5)
|
|||
/* deletes an md5 from an index */
|
||||
{
|
||||
int status = 404;
|
||||
FILE *l, *i, *o;
|
||||
|
||||
if ((l = index_lock(fn)) == NULL)
|
||||
return 500;
|
||||
FILE *i, *o;
|
||||
|
||||
if ((i = fopen(fn, "r")) != NULL) {
|
||||
flock(fileno(i), LOCK_EX);
|
||||
|
@ -335,8 +309,6 @@ int index_del_md5(const char *fn, const char *md5)
|
|||
else
|
||||
status = 500;
|
||||
|
||||
index_unlock(l, fn);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue