Skip to content

Commit 7a485ed

Browse files
fix(macos): resolucao incondicional de DB no Application Support, permissao ATS local no Info.plist e teste unitario de persistencia
1 parent db30aaf commit 7a485ed

4 files changed

Lines changed: 52 additions & 13 deletions

File tree

‎build/darwin/Info.plist‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
<key>CFBundleIdentifier</key>
1414
<string>com.ademartellecher.ipmonitorapp</string>
1515
<key>CFBundleVersion</key>
16-
<string>2.4.1</string>
16+
<string>2.4.2</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.4.1</string>
18+
<string>2.4.2</string>
1919
<key>CFBundleIconFile</key>
2020
<string>AppIcon</string>
2121
<key>LSMinimumSystemVersion</key>
@@ -26,6 +26,13 @@
2626
<true/>
2727
<key>LSUIElement</key>
2828
<false/>
29+
<key>NSAppTransportSecurity</key>
30+
<dict>
31+
<key>NSAllowsLocalNetworking</key>
32+
<true/>
33+
<key>NSAllowsArbitraryLoads</key>
34+
<true/>
35+
</dict>
2936
<key>NSHumanReadableCopyright</key>
3037
<string>Copyright © 2026 Ademar Tellecher. All rights reserved.</string>
3138
</dict>

‎frontend/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
<span class="nav-label">Sobre</span>
112112
<div class="about-tooltip-popover" id="aboutPopover">
113113
<div class="tooltip-header">
114-
<div class="tooltip-badge">v2.4.1</div>
114+
<div class="tooltip-badge">v2.4.2</div>
115115
<span class="tooltip-title">IP Monitor App</span>
116116
</div>
117117
<p class="tooltip-text">Monitoramento de conectividade ICMP Ping em tempo real, ultra-leve e portátil.</p>

‎internal/model/model.go‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"os"
66
"path/filepath"
77
"runtime"
8-
"strings"
98

109
_ "modernc.org/sqlite"
1110
)
@@ -19,14 +18,11 @@ func ResolveDBPath(defaultName string) string {
1918
}
2019

2120
if runtime.GOOS == "darwin" {
22-
exePath, err := os.Executable()
23-
if err == nil && strings.Contains(exePath, ".app/Contents/MacOS") {
24-
homeDir, err := os.UserHomeDir()
25-
if err == nil {
26-
appSupportDir := filepath.Join(homeDir, "Library", "Application Support", "IPMonitor")
27-
_ = os.MkdirAll(appSupportDir, 0755)
28-
return filepath.Join(appSupportDir, defaultName)
29-
}
21+
homeDir, err := os.UserHomeDir()
22+
if err == nil {
23+
appSupportDir := filepath.Join(homeDir, "Library", "Application Support", "IPMonitor")
24+
_ = os.MkdirAll(appSupportDir, 0755)
25+
return filepath.Join(appSupportDir, defaultName)
3026
}
3127
}
3228

@@ -215,9 +211,14 @@ func (repo *IPRepository) List() ([]IPDevice, error) {
215211
var devices []IPDevice
216212
for rows.Next() {
217213
var d IPDevice
218-
_ = rows.Scan(&d.ID, &d.IP, &d.Status, &d.Name, &d.Method, &d.ThresholdMs, &d.UUID)
214+
if err := rows.Scan(&d.ID, &d.IP, &d.Status, &d.Name, &d.Method, &d.ThresholdMs, &d.UUID); err != nil {
215+
return nil, err
216+
}
219217
devices = append(devices, d)
220218
}
219+
if err := rows.Err(); err != nil {
220+
return nil, err
221+
}
221222
return devices, nil
222223
}
223224

‎internal/model/model_test.go‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package model
2+
3+
import (
4+
"os"
5+
"path/filepath"
6+
"runtime"
7+
"testing"
8+
)
9+
10+
func TestResolveDBPath(t *testing.T) {
11+
dbName := "test_monitor.db"
12+
path := ResolveDBPath(dbName)
13+
14+
if runtime.GOOS == "darwin" {
15+
homeDir, err := os.UserHomeDir()
16+
if err == nil {
17+
expected := filepath.Join(homeDir, "Library", "Application Support", "IPMonitor", dbName)
18+
if path != expected {
19+
t.Fatalf("Esperava caminho %s no macOS, mas obteve: %s", expected, path)
20+
}
21+
}
22+
} else {
23+
exePath, err := os.Executable()
24+
if err == nil {
25+
expected := filepath.Join(filepath.Dir(exePath), dbName)
26+
if path != expected {
27+
t.Fatalf("Esperava caminho %s, mas obteve: %s", expected, path)
28+
}
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)