Skip to content

Commit 4555a5d

Browse files
committed
Unlink tmp file
1 parent 993054e commit 4555a5d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Encoding.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,25 @@ public function encodeFile($file, $encoding_to = 'UTF-8', $encodings_detected =
2727
if (fwrite($handleW, mb_convert_encoding($line, $encoding_to, $encoding_original), 4096) === false) {
2828
fclose($handleR);
2929
fclose($handleW);
30+
unlink($fileW);
3031

3132
return false;
3233
}
3334
}
3435
fclose($handleR);
3536
fclose($handleW);
3637
if (rename($fileW, $file) === false) {
38+
unlink($fileW);
3739
return false;
3840
}
3941
} else {
4042
return false;
4143
}
4244
} catch (Exception $e) {
45+
if (file_exits($fileW)) {
46+
unlink($fileW);
47+
}
48+
4349
return false;
4450
}
4551
}

0 commit comments

Comments
 (0)