Skip to content

Commit a84f7ef

Browse files
committed
feat: 修复临时文件目录获取逻辑,确保在不同环境下正确创建临时文件
1 parent 3349bdf commit a84f7ef

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

app/src/main/java/com/muort/upworker/feature/scripteditor/ScriptEditorViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class ScriptEditorViewModel @Inject constructor(
167167
Timber.d("Original content length: ${content.length}, Fixed: ${fixedContent.length}")
168168

169169
// Create temporary file
170-
val tempDir = java.io.File(System.getProperty("java.io.tmpdir"))
170+
val tempDir = java.io.File(System.getProperty("java.io.tmpdir") ?: System.getenv("TEMP") ?: "/tmp")
171171
val tempFile = java.io.File(tempDir, "$scriptName.js")
172172

173173
try {

app/src/main/java/com/muort/upworker/feature/worker/WorkerViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class WorkerViewModel @Inject constructor(
3333
val content = scriptFile.readText(Charsets.UTF_8)
3434

3535
// 创建临时文件
36-
val tempDir = java.io.File(System.getProperty("java.io.tmpdir"))
36+
val tempDir = java.io.File(System.getProperty("java.io.tmpdir") ?: System.getenv("TEMP") ?: "/tmp")
3737
val tempFile = java.io.File(tempDir, "$scriptName.js")
3838

3939
try {

0 commit comments

Comments
 (0)