{"record":{"id":"92587e89ad66baa1","repo":"Tencent/matrix","slug":"file-outputfile-getabsolutepath-is-alread","errorCode":null,"errorMessage":"---File '<outputFile.getAbsolutePath()>' is already exists!","messagePattern":"---File '<outputFile\\.getAbsolutePath\\(\\)>' is already exists!","errorType":"exception","errorClass":"TaskExecuteException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/UnzipTask.java","lineNumber":246,"sourceCode":"                zipInputStream.close();\n            }\n            if (bufferedOutput != null) {\n                bufferedOutput.close();\n            }\n        }\n        return outEntryName;\n    }\n\n    @Override\n    public TaskResult call() throws TaskExecuteException {\n        ZipFile zipFile = null;\n        try {\n            zipFile = new ZipFile(inputFile);\n            if (outputFile.isDirectory() && outputFile.exists()) {\n                Log.i(TAG, \"%s exists, delete it.\", outputFile.getAbsolutePath());\n                FileUtils.deleteDirectory(outputFile);\n            } else if (outputFile.isFile()) {\n                throw new TaskExecuteException(TAG + \"---File '\" + outputFile.getAbsolutePath() + \"' is already exists!\");\n            }\n            TaskResult taskResult = TaskResultFactory.factory(getType(), TASK_RESULT_TYPE_JSON, config);\n            if (taskResult == null) {\n                return null;\n            }\n            long startTime = System.currentTimeMillis();\n            if (!outputFile.mkdir()) {\n                throw new TaskExecuteException(TAG + \"---Create directory '\" + outputFile.getAbsolutePath() + \"' failed!\");\n            }\n\n            ((TaskJsonResult) taskResult).add(\"total-size\", inputFile.length());\n\n            readMappingTxtFile();\n            config.setProguardClassMap(proguardClassMap);\n            ResguardUtil.readResMappingTxtFile(resMappingTxt, resDirMap, resguardMap);\n            config.setResguardMap(resguardMap);\n\n            Enumeration entries = zipFile.entries();","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/UnzipTask.java#L228-L264","documentation":"During UnzipTask.call() execution, if the configured unzip output path resolves to an existing regular file (not a directory) the task cannot create its output directory there and throws TaskExecuteException. Directories are deleted and recreated; plain files are treated as a conflict.","triggerScenarios":"config.getUnzipPath() points to an existing file (e.g. a zip archive or a leftover file) instead of a directory.","commonSituations":"Pointing unzip output at the APK file itself or at some artifact file; a previous run left a file at that path; misconfigured output path colliding with an existing build artifact.","solutions":["Delete the file at the configured unzip path, or choose a different output directory.","Ensure unzipPath denotes a directory location (ending with a directory name not used by any file).","Add pre-run cleanup in your build script that removes the unzip output location."],"exampleFix":"// before\nconfig.setUnzipPath(\"build/outputs/apk/release/app-release.apk\"); // a file\n// after\nconfig.setUnzipPath(\"build/matrix/unzip-output\");","handlingStrategy":"validation","validationCode":"File out = new File(config.getUnzipPath());\nif (out.isFile()) {\n    throw new IllegalArgumentException(\"unzipPath is an existing file: \" + out.getAbsolutePath());\n}","typeGuard":null,"tryCatchPattern":"try {\n    task.call();\n} catch (TaskExecuteException e) {\n    if (e.getMessage().contains(\"is already exists\")) {\n        new File(config.getUnzipPath()).delete();\n        task.call(); // retry after removing the conflicting file\n    } else throw e;\n}","preventionTips":["Dedicate a directory to unzip output that no other task writes files into.","Wipe the unzip output location at the start of your build pipeline."],"tags":["apk-canary","file-already-exists","output-path"],"backgroundTag":"file-already-exists","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}