Lines 600-605
inotify_remove_file(const char * path)
Link Here
|
600 |
sql_exec(db, "DELETE from OBJECTS where DETAIL_ID = %lld", detailID); |
600 |
sql_exec(db, "DELETE from OBJECTS where DETAIL_ID = %lld", detailID); |
601 |
} |
601 |
} |
602 |
snprintf(art_cache, sizeof(art_cache), "%s/art_cache%s", db_path, path); |
602 |
snprintf(art_cache, sizeof(art_cache), "%s/art_cache%s", db_path, path); |
|
|
603 |
|
604 |
#ifdef THUMBNAIL_CREATION |
605 |
/* Remove video thumbnails */ |
606 |
if ( is_video(path) ) |
607 |
{ |
608 |
char *vthumb = art_cache; |
609 |
strcpy(strchr(vthumb, '\0')-4, ".jpg"); |
610 |
} |
611 |
#endif |
612 |
|
603 |
remove(art_cache); |
613 |
remove(art_cache); |
604 |
|
614 |
|
605 |
return 0; |
615 |
return 0; |
Lines 649-655
start_inotify()
Link Here
|
649 |
int length, i = 0; |
659 |
int length, i = 0; |
650 |
char * esc_name = NULL; |
660 |
char * esc_name = NULL; |
651 |
struct stat st; |
661 |
struct stat st; |
652 |
|
662 |
#ifdef THUMBNAIL_CREATION |
|
|
663 |
char renpath_buf[PATH_MAX]; |
664 |
int cookie = 0; |
665 |
#endif |
666 |
|
653 |
pollfds[0].fd = inotify_init(); |
667 |
pollfds[0].fd = inotify_init(); |
654 |
pollfds[0].events = POLLIN; |
668 |
pollfds[0].events = POLLIN; |
655 |
|
669 |
|
Lines 710-715
start_inotify()
Link Here
|
710 |
{ |
724 |
{ |
711 |
DPRINTF(E_DEBUG, L_INOTIFY, "The directory %s was %s.\n", |
725 |
DPRINTF(E_DEBUG, L_INOTIFY, "The directory %s was %s.\n", |
712 |
path_buf, (event->mask & IN_MOVED_TO ? "moved here" : "created")); |
726 |
path_buf, (event->mask & IN_MOVED_TO ? "moved here" : "created")); |
|
|
727 |
#ifdef THUMBNAIL_CREATION |
728 |
/* We do not want to regenerate the thumbnails if e rename a directory. |
729 |
We should keep at least four cookies/olddir since IN_MOVED_FROM/IN_MOVED_TO may |
730 |
not arrive in sequence, but one should cover most cases */ |
731 |
if (event->cookie == cookie && event->mask & IN_MOVED_TO) |
732 |
{ |
733 |
DPRINTF(E_DEBUG, L_INOTIFY, "Directory rename: %s -> %s \n", renpath_buf, path_buf); |
734 |
rename_artcache_dir(renpath_buf, path_buf); |
735 |
} |
736 |
#endif |
713 |
inotify_insert_directory(pollfds[0].fd, esc_name, path_buf); |
737 |
inotify_insert_directory(pollfds[0].fd, esc_name, path_buf); |
714 |
} |
738 |
} |
715 |
else if ( (event->mask & (IN_CLOSE_WRITE|IN_MOVED_TO|IN_CREATE)) && |
739 |
else if ( (event->mask & (IN_CLOSE_WRITE|IN_MOVED_TO|IN_CREATE)) && |
Lines 741-747
start_inotify()
Link Here
|
741 |
(event->mask & IN_ISDIR ? "directory" : "file"), |
765 |
(event->mask & IN_ISDIR ? "directory" : "file"), |
742 |
path_buf, (event->mask & IN_MOVED_FROM ? "moved away" : "deleted")); |
766 |
path_buf, (event->mask & IN_MOVED_FROM ? "moved away" : "deleted")); |
743 |
if ( event->mask & IN_ISDIR ) |
767 |
if ( event->mask & IN_ISDIR ) |
|
|
768 |
#ifdef THUMBNAIL_CREATION |
769 |
{ |
770 |
if ( event->mask & IN_MOVED_FROM ) |
771 |
{ |
772 |
strncpy(renpath_buf, path_buf, sizeof(renpath_buf)); |
773 |
cookie = event->cookie; |
774 |
} |
775 |
#endif |
744 |
inotify_remove_directory(pollfds[0].fd, path_buf); |
776 |
inotify_remove_directory(pollfds[0].fd, path_buf); |
|
|
777 |
#ifdef THUMBNAIL_CREATION |
778 |
} |
779 |
#endif |
745 |
else |
780 |
else |
746 |
inotify_remove_file(path_buf); |
781 |
inotify_remove_file(path_buf); |
747 |
} |
782 |
} |