diff --git a/src/module/module_repo.c b/src/module/module_repo.c index 3969e2acd932a26eaccf8f4f805b27697172a064..0fef215106c23e2a0829ed2cec83233cd3a79bc8 100644 --- a/src/module/module_repo.c +++ b/src/module/module_repo.c @@ -102,6 +102,17 @@ struct __file { * Private functions * *********************/ +/* Sleep a bit, to not overuse ressources */ +static inline void +__sleep(void) +{ + struct timespec time_sleep = { + .tv_sec = 0, + .tv_nsec = 100000000L, + }; /* Sleep for 0.1s */ + nanosleep(&time_sleep, NULL); /* Sleep a bit, better for Hard drive */ +} + /* Recursive mkdir, where the last word of the string is a file, not a folder. */ static inline void __mkdir(const char *dir, unsigned int umask) @@ -393,11 +404,7 @@ __handle_got_json_internal_callback(const char *key, const char *val, int comp, /* The `void *user` is complete */ else if (comp) { - struct timespec time_sleep = { - .tv_sec = 0, - .tv_nsec = 100000000L, - }; /* Sleep for 0.1s */ - nanosleep(&time_sleep, NULL); /* Sleep a bit, better for Hard drive */ + __sleep(); long filestamp = 0; int current_id = 0; @@ -559,6 +566,8 @@ __handle_fav_list_internal(const char UNUSED *key, const char *val, int UNUSED c LOG_ERROR("REPO", "Failed to add kara %ld to playlist %s", uri->uri.id, uri->fav); return; } + /* Dirty fix for db lock and hard drive usage */ + __sleep(); }