Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
324f7959
Commit
324f7959
authored
Jan 20, 2026
by
Johnny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: improve default data directory handling
parent
d3ed069d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
10 deletions
+19
-10
profile.go
internal/profile/profile.go
+19
-10
No files found.
internal/profile/profile.go
View file @
324f7959
...
...
@@ -54,19 +54,28 @@ func checkDataDir(dataDir string) (string, error) {
}
func
(
p
*
Profile
)
Validate
()
error
{
if
!
p
.
Demo
&&
p
.
Data
==
""
{
// Set default data directory if not specified
if
p
.
Data
==
""
{
if
p
.
Demo
{
// In demo mode, use a temporary directory or current directory
p
.
Data
=
"."
}
else
{
// In production mode, use system directory
if
runtime
.
GOOS
==
"windows"
{
p
.
Data
=
filepath
.
Join
(
os
.
Getenv
(
"ProgramData"
),
"memos"
)
}
else
{
p
.
Data
=
"/var/opt/memos"
}
}
}
// Create data directory if it doesn't exist
if
_
,
err
:=
os
.
Stat
(
p
.
Data
);
os
.
IsNotExist
(
err
)
{
if
err
:=
os
.
MkdirAll
(
p
.
Data
,
0770
);
err
!=
nil
{
slog
.
Error
(
"failed to create data directory"
,
slog
.
String
(
"data"
,
p
.
Data
),
slog
.
String
(
"error"
,
err
.
Error
()))
return
err
}
}
}
else
{
p
.
Data
=
"/var/opt/memos"
}
}
dataDir
,
err
:=
checkDataDir
(
p
.
Data
)
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment