Fixed the bugs in synchronizing files only when necessary