Gallery: fix infinite recursion in thumbnail updater is some cases