Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
argo
cuttr
Commits
bfead0fa
Commit
bfead0fa
authored
Sep 27, 2018
by
Alexis Janon
Browse files
check_path for find_get_set and get_set primitives
parent
174fce88
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/transaction/fs/find_get_set_value.rs
View file @
bfead0fa
...
...
@@ -59,6 +59,9 @@ impl Command for FindGetSetValue {
Some
(
ref
value
)
=>
value
,
None
=>
return
Err
(
Error
::
from
(
format!
(
"Missing previous value for path {:?}. (probably an internal bug, you should report it)"
,
self
.path
)))
};
if
let
Err
(
err
)
=
self
.controllers
.check_path
(
&
path
)
{
return
Err
(
err
);
}
trace!
(
"Reading from file {:?}"
,
path
);
let
old_value
=
fs
::
read_to_string
(
path
)
.map_err
(|
err
|
{
Error
::
from
(
format!
(
...
...
@@ -111,6 +114,9 @@ impl Command for FindGetSetValue {
}
}
};
if
let
Err
(
err
)
=
self
.controllers
.check_path
(
&
path
)
{
return
Err
(
err
);
}
debug!
(
"{{rollback}} Reading and writing to file {:?}"
,
path
);
let
old_value
=
match
self
.old_value
{
Some
(
ref
value
)
=>
value
,
...
...
src/transaction/fs/get_set_value.rs
View file @
bfead0fa
use
configuration
::
sysfscontroller
::
SysFsControllerList
;
use
std
::
fs
;
use
std
::
path
::
PathBuf
;
use
std
::
rc
::
Rc
;
use
transaction
::
*
;
#[derive(Clone,
PartialEq,
Eq)]
...
...
@@ -7,20 +9,25 @@ pub struct GetSetValue {
path
:
PathBuf
,
value
:
String
,
old_value
:
Option
<
String
>
,
controllers
:
Rc
<
SysFsControllerList
>
,
}
impl
GetSetValue
{
pub
fn
new
(
path
:
PathBuf
,
value
:
String
)
->
Self
{
pub
fn
new
(
path
:
PathBuf
,
value
:
String
,
controllers
:
Rc
<
SysFsControllerList
>
)
->
Self
{
GetSetValue
{
path
,
value
,
old_value
:
None
,
controllers
,
}
}
}
impl
Command
for
GetSetValue
{
fn
exec
(
&
mut
self
)
->
Result
<
CommandResult
>
{
if
let
Err
(
err
)
=
self
.controllers
.check_path
(
&
self
.path
)
{
return
Err
(
err
);
}
if
!
self
.path
.exists
()
{
warn!
(
"Could not find file {:?}"
,
self
.path
);
return
Ok
(
CommandResult
::
from
(()));
...
...
@@ -53,6 +60,9 @@ impl Command for GetSetValue {
}
fn
rollback
(
&
mut
self
)
->
Result
<
CommandResult
>
{
if
let
Err
(
err
)
=
self
.controllers
.check_path
(
&
self
.path
)
{
return
Err
(
err
);
}
debug!
(
"{{rollback}} Reading and writing {:?}"
,
self
.path
);
let
old_value
=
match
self
.old_value
{
Some
(
ref
value
)
=>
value
,
...
...
src/transaction/hl/exec.rs
View file @
bfead0fa
...
...
@@ -33,8 +33,9 @@ impl Exec {
.values
()
.map
(
SysFsController
::
get_tasks_filename
),
)
.map
(|(
path
,
tasks_filename
)|
path
.join
(
&
name
)
.join
(
tasks_filename
))
.map
(|
path
|
GetSetValue
::
new
(
path
.to_path_buf
(),
"0"
.to_owned
()))
.map
(
Box
::
new
)
.map
(|
path
|
{
GetSetValue
::
new
(
path
.to_path_buf
(),
"0"
.to_owned
(),
Rc
::
clone
(
&
controllers
))
})
.map
(
Box
::
new
)
.map
(|
b
|
b
as
Box
<
Command
>
)
.collect
::
<
Vec
<
_
>>
();
let
mut
process_cmd
=
process
::
Command
::
new
(
cmd
);
...
...
Alexis Janon
@ajanon
mentioned in commit
1924e567
·
Sep 27, 2018
mentioned in commit
1924e567
mentioned in commit 1924e567fe652e7288a8fd896d60f9bcef8e363c
Toggle commit list
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