Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4ae4a479
Commit
4ae4a479
authored
Jan 16, 2019
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update pages config only when changed
parent
267ce96e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
3 deletions
+20
-3
app/services/projects/update_pages_configuration_service.rb
app/services/projects/update_pages_configuration_service.rb
+20
-3
No files found.
app/services/projects/update_pages_configuration_service.rb
View file @
4ae4a479
...
@@ -9,8 +9,10 @@ module Projects
...
@@ -9,8 +9,10 @@ module Projects
end
end
def
execute
def
execute
update_file
(
pages_config_file
,
pages_config
.
to_json
)
if
update_file
(
pages_config_file
,
pages_config
.
to_json
)
reload_daemon
reload_daemon
end
success
success
rescue
=>
e
rescue
=>
e
error
(
e
.
message
)
error
(
e
.
message
)
...
@@ -69,7 +71,12 @@ module Projects
...
@@ -69,7 +71,12 @@ module Projects
def
update_file
(
file
,
data
)
def
update_file
(
file
,
data
)
unless
data
unless
data
FileUtils
.
remove
(
file
,
force:
true
)
FileUtils
.
remove
(
file
,
force:
true
)
return
return
true
end
existing_data
=
read_file
(
file
)
if
data
==
existing_data
return
false
end
end
temp_file
=
"
#{
file
}
.
#{
SecureRandom
.
hex
(
16
)
}
"
temp_file
=
"
#{
file
}
.
#{
SecureRandom
.
hex
(
16
)
}
"
...
@@ -77,9 +84,19 @@ module Projects
...
@@ -77,9 +84,19 @@ module Projects
f
.
write
(
data
)
f
.
write
(
data
)
end
end
FileUtils
.
move
(
temp_file
,
file
,
force:
true
)
FileUtils
.
move
(
temp_file
,
file
,
force:
true
)
true
ensure
ensure
# In case if the updating fails
# In case if the updating fails
FileUtils
.
remove
(
temp_file
,
force:
true
)
FileUtils
.
remove
(
temp_file
,
force:
true
)
end
end
def
read_file
(
file
)
File
.
open
(
file
,
'r'
)
do
|
f
|
f
.
read
end
rescue
nil
end
end
end
end
end
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