Skip to content

Commit

Permalink
解决保存管理应用配置时配置目录处理错误
Browse files Browse the repository at this point in the history
  • Loading branch information
Qi, Xiaoqiang committed Sep 29, 2024
1 parent 8e7b2f5 commit 9d37ae6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,14 @@ function getAllSharefolder()
/*
* 保存管理程序的配置到配置文件中
*/
function saveManageConfig($appDir, $manageConfigData) {
function saveManageConfig($manageConfigDir, $manageConfigData) {
// 将配置换成JSON格式
$manageConfigJson = json_encode($manageConfigData);
// 管理应用配置目录
$manageConfigDir = $hmoesExtAppsFolder.$appDir;
// 判断管理应用配置目录是否存在
if (!is_dir($manageConfigDir)) {
// 文件夹不存在,创建文件夹
exec("sudo mkdir -p $manageConfigDir");
// 此处不判断是否创建成功,交由后续判断统一处理
// 文件夹不存在,创建文件夹
exec("sudo mkdir -p $manageConfigDir");
// 此处不判断是否创建成功,交由后续判断统一处理
}
// 修改管理应用目录权限和所有者
exec("sudo chown www-data:www-data $manageConfigDir");
Expand All @@ -216,9 +215,9 @@ function saveManageConfig($appDir, $manageConfigData) {
// 管理应用配置文件
$manageConfigFile = $manageConfigDir.'/config.json';
if(file_exists($manageConfigFile)) {
// 如果配置文件存在,则修改文件权限和所有者
exec("sudo chown www-data:www-data $manageConfigFile");
exec("sudo chmod 644 $manageConfigFile");
// 如果配置文件存在,则修改文件权限和所有者
exec("sudo chown www-data:www-data $manageConfigFile");
exec("sudo chmod 644 $manageConfigFile");
}
// 将JSON数据写入文件
return file_put_contents($manageConfigFile, $manageConfigJson);
Expand Down
2 changes: 1 addition & 1 deletion includes/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
'configDir' => $configDir,
'port' => $port
);
$result = saveManageConfig('/alist', $manageConfigData);
$result = saveManageConfig($hmoesExtAppsFolder.'/alist', $manageConfigData);
if($result == false) {
// 配置写入文件失败
echo json_encode(array(
Expand Down

0 comments on commit 9d37ae6

Please sign in to comment.