mirror of
https://github.com/systemd/systemd.git
synced 2024-10-27 10:25:37 +03:00
core: optimize unit_write_drop_in a bit
There's no point in first determining the drop-in file name path, then forgetting it again, and then determining it again. Instead, just generated it once, and then write to ti directly.
This commit is contained in:
parent
e20b2a867a
commit
815b09d39b
@ -3379,18 +3379,20 @@ int unit_write_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name, co
|
||||
prefixed = strjoina("# This is a drop-in unit file extension, created via \"systemctl set-property\" or an equivalent operation. Do not edit.\n",
|
||||
data);
|
||||
|
||||
r = write_drop_in(dir, u->id, 50, name, prefixed);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = drop_in_file(dir, u->id, 50, name, &p, &q);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = strv_extend(&u->dropin_paths, q);
|
||||
(void) mkdir_p(p, 0755);
|
||||
r = write_string_file_atomic_label(q, prefixed);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = strv_push(&u->dropin_paths, q);
|
||||
if (r < 0)
|
||||
return r;
|
||||
q = NULL;
|
||||
|
||||
strv_uniq(u->dropin_paths);
|
||||
|
||||
u->dropin_mtime = now(CLOCK_REALTIME);
|
||||
|
Loading…
Reference in New Issue
Block a user