Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a67bc110 authored by Kan-Ru Chen's avatar Kan-Ru Chen
Browse files

acp: Ensure dst mtime always greater or equal to src mtime

When copying files from file systems that support high resolution
mtime, we should not truncating the nsec part. Instead we should
increase the dst mtime by one sec to prevent dst mtime to become less
than src mtime.

Change-Id: I5cab1edd4b9783ec0e3ceb04ed833d8bbba00b19
parent 45038e06
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -151,6 +151,12 @@ static int setPermissions(const char* dst, const struct stat* pSrcStat, unsigned
         */
         */
        ut.actime = pSrcStat->st_atime;
        ut.actime = pSrcStat->st_atime;
        ut.modtime = pSrcStat->st_mtime;
        ut.modtime = pSrcStat->st_mtime;
#ifdef MACOSX_RSRC
        if (pSrcStat->st_mtimespec.tv_nsec > 0)
#else
        if (pSrcStat->st_mtim.tv_nsec > 0)
#endif
            ut.modtime += 1;
        if (utime(dst, &ut) != 0) {
        if (utime(dst, &ut) != 0) {
            DBUG(("---   unable to set timestamps on '%s': %s\n",
            DBUG(("---   unable to set timestamps on '%s': %s\n",
                dst, strerror(errno)));
                dst, strerror(errno)));