Skip to content

Conversation

@sabonerune
Copy link
Contributor

内容

electron-logがインポートすると自動的にログディレクトリを作成してしまうこと、初期状態でapp.getPath("userData")を実行すると自動的にディレクトリを作成してしまうことが原因でした。

このためelectron-logを問題が修正された5.0.0へ更新、
beforeUserDataDirを取得した後、そのディレクトリを削除することで問題を解決します。

関連 Issue

その他

ref electron-log

portManager.ts!== undefinedを修正
vvppManager.ts=== nullを修正

electron-logをv5へ
app.getPath("userData")で作成されてしまうディレクトリを一度削除するようにした

一部の===undefinedを修正
@sabonerune sabonerune requested a review from a team as a code owner October 25, 2023 13:16
@sabonerune sabonerune requested review from y-chan and removed request for a team October 25, 2023 13:16
Comment on lines +158 to +161
ipcRenderer.send("__ELECTRON_LOG__", {
data: [...params],
level: "error",
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/megahertz/electron-log/blob/master/README.md#renderer-process

import log from 'electron-log/renderer';
log.info('Log from the renderer process');

わざわざ手動で呼び出す必要はないような感じがします、何か問題とかあったらコメントがあると判りやすいかと。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

以前のバージョンでもプリロードでelectron-logをインポートしていなかったのでそれに倣った感じです。

また、具体的な問題は発生していませんが

  • レンダラープロセスの状態をブラウザ版と可能な限り変えない方がいいと感じた。
  • log.initialize({ preload: true });で呼び出すとuserDataディレクトリにelectron-log-preload.jsが作成されるという挙動に怪しさを感じた。

というのもあります。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ブラウザ版の考慮はすごい納得感ありました。
ここでelectron-logをimportするのはまあOKだと思いますが、userDataにjsファイルが作られるのはちょっとよくわかんないですね・・・。

まあドキュメントでも案内されてる方法ですし、この形が良いのかなと思いました。
https://github.com/megahertz/electron-log/blob/19bb2a1ab5e12eb985f87cae058d54f6970c7d49/docs/initialize.md#using-ipc-directly

コメントは1箇所あると良さそうですね!
ここのやりとりへのリンクをコメントする感じとか。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なるほと。コメントあれば大丈夫だと思います。

Copy link
Member

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

・・・なのですが、正直ちょっとしばらく様子見したいなという気持ちもちょっとあります 😇
メジャーバージョンアプデなので、なんか大きくガラッと仕様変わったらやだな~くらいの気持ちです。

・・・2週間待機とかでどうでしょう!

// バージョン0.14より前の設定ファイルの保存場所
const beforeUserDataDir = app.getPath("userData"); // マイグレーション用

// app.getPath("userData")を呼ぶとディレクトリが作成されてしまうため空なら削除する。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これ・・・・・悲しいですね・・・・。

Comment on lines +158 to +161
ipcRenderer.send("__ELECTRON_LOG__", {
data: [...params],
level: "error",
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ブラウザ版の考慮はすごい納得感ありました。
ここでelectron-logをimportするのはまあOKだと思いますが、userDataにjsファイルが作られるのはちょっとよくわかんないですね・・・。

まあドキュメントでも案内されてる方法ですし、この形が良いのかなと思いました。
https://github.com/megahertz/electron-log/blob/19bb2a1ab5e12eb985f87cae058d54f6970c7d49/docs/initialize.md#using-ipc-directly

コメントは1箇所あると良さそうですね!
ここのやりとりへのリンクをコメントする感じとか。

@Hiroshiba
Copy link
Member

マージします!

@Hiroshiba Hiroshiba merged commit efcea1f into VOICEVOX:main Oct 26, 2023
Comment on lines +74 to +82
try {
fs.rmdirSync(beforeUserDataDir, { recursive: false });
} catch (e) {
const err = e as NodeJS.ErrnoException;
if (err?.code !== "ENOTEMPTY") {
log.error(err);
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hiroshiba マージした後ですみません。

electron-logの初期化や設定前にlog.error(err);を呼びだしてしまっているのでNOTENPTY以外のエラーが起きた時beforeUserDataDirの方にログを作成してしまうことに気が付きました。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

おっとなるほどです!!気づいてくださってありがとうございます!
修正プルリクエストをお願いしても良いでしょうか?
(こちらで良い感じに直しておくのももちろんOKです!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修正PR出そうと思います。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

voicevox-cpuという設定・ログディレクトリが作られてしまう

3 participants