{"record":{"id":"71c16c1d7d4a8543","repo":"quarkusio/quarkus","slug":"failed-to-restore-the-timestamp-of-the-file","errorCode":null,"errorMessage":"Failed to restore the timestamp of the file: ","messagePattern":"Failed to restore the timestamp of the file: ","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/util/CustomFileSystemOperations.java","lineNumber":198,"sourceCode":"        }\n\n        copy.into(config.destination);\n\n        if (!config.includes.isEmpty()) {\n            copy.include(config.includes);\n        }\n\n        if (!config.excludes.isEmpty()) {\n            copy.exclude(config.excludes);\n        }\n    }\n\n    private static void restoreTimestamps(List<CopiedFileMetadata> copiedFilesMetadata) {\n        for (CopiedFileMetadata m : copiedFilesMetadata) {\n            try {\n                Files.setLastModifiedTime(m.destination(), m.sourceMtime());\n            } catch (IOException e) {\n                throw new GradleException(\"Failed to restore the timestamp of the file: \" + m.destination(), e);\n            }\n        }\n    }\n\n}\n","sourceCodeStart":180,"sourceCodeEnd":204,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/util/CustomFileSystemOperations.java#L180-L204","documentation":"Thrown by the Quarkus Gradle plugin's CustomFileSystemOperations when it cannot set the last-modified time of a copied file back to the source file's timestamp. During timestamp-preserving copies/syncs the plugin records each copied file's source mtime and destination path, then replays those mtimes with Files.setLastModifiedTime; an IOException there is wrapped in this GradleException.","triggerScenarios":"Files.setLastModifiedTime throws while iterating CopiedFileMetadata entries after a copyPreservingTimestamps or syncPreservingTimestamps call — typically because the destination file was deleted/moved mid-operation, the destination is read-only, or the process lacks write permission on the output directory.","commonSituations":"Running Gradle builds as different users (e.g. root-created files then non-root build), CI containers with restricted file ownership, antivirus/backup tools locking destination files, or read-only mounted build output directories.","solutions":["Check ownership and write permissions on the destination file/directory; fix with chown/chmod or run Gradle as a user that owns the build output.","Verify no external process (antivirus, sync client, IDE) is deleting or locking files in the output directory during the build.","Clean the build (gradle clean or delete the output dir) to remove stale files with wrong ownership.","Ensure the destination filesystem supports setting modification times (some network/overlay filesystems do not)."],"exampleFix":"// before: files copied into a root-owned dir\nquarkusSync { into 'build/quarkus-app' }\n// after: ensure the dir is writable before the task\n/tasks.named('quarkusSync') { doFirst { def d = file('build/quarkus-app'); d.mkdirs(); assert d.canWrite() } }/","handlingStrategy":"try-catch","validationCode":"// before the copy task\ndef dest = project.file('build/quarkus-app')\nif (dest.exists() && !dest.canWrite()) throw new IllegalStateException(\"Output dir not writable: $dest\")\nif (dest.exists() && Files.getOwner(dest.toPath()).name != System.getProperty('user.name')) {\n  logger.warn('Output dir owned by another user; clean the build first')\n}","typeGuard":null,"tryCatchPattern":"try {\n  copyPreservingTimestamps(spec)\n} catch (GradleException e) {\n  def f = e.message.minus('Failed to restore the timestamp of the file: ')\n  def file = new File(f)\n  file.delete() // drop the unreadable/locked output and retry once\n  copyPreservingTimestamps(spec)\n}","preventionTips":["Run all Gradle invocations (including IDE sync) as the same OS user.","Exclude build/ directories from antivirus and file-sync tools.","Run gradle clean after switching users or containers for the same workspace.","Avoid output directories on filesystems that don't support mtime updates (some NFS/network mounts)."],"tags":["gradle","filesystem","ioexception","permissions"],"backgroundTag":"file-permission-denied","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}