重构: App拆分10域文件+并发安全+结构化日志+依赖升级
This commit is contained in:
@@ -20,8 +20,8 @@ func NewFileLockChecker() *FileLockChecker {
|
||||
// IsFileLocked 检查文件是否被锁定(被其他进程占用)
|
||||
// 返回: (是否锁定, 错误信息, 错误)
|
||||
func (c *FileLockChecker) IsFileLocked(path string) (bool, string, error) {
|
||||
// 尝试以独占写模式打开文件
|
||||
file, err := os.OpenFile(path, os.O_RDWR|syscall.O_CREAT, 0666)
|
||||
// 尝试以独占写模式打开文件(不创建新文件)
|
||||
file, err := os.OpenFile(path, os.O_RDWR, 0)
|
||||
if err != nil {
|
||||
// 检查是否是锁相关的错误
|
||||
if isLockError(err) {
|
||||
|
||||
Reference in New Issue
Block a user