Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nora Puchreiner
Nix
Commits
ff4de4cb
Commit
ff4de4cb
authored
9 years ago
by
Eelco Dolstra
Browse files
Options
Downloads
Patches
Plain Diff
GC: Handle ENOSPC creating/moving to the trash directory
Issue #564.
parent
2bc9c843
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libstore/gc.cc
+23
-8
23 additions, 8 deletions
src/libstore/gc.cc
with
23 additions
and
8 deletions
src/libstore/gc.cc
+
23
−
8
View file @
ff4de4cb
...
...
@@ -376,6 +376,7 @@ struct LocalStore::GCState
bool
gcKeepOutputs
;
bool
gcKeepDerivations
;
unsigned
long
long
bytesInvalidated
;
bool
moveToTrash
=
true
;
Path
trashDir
;
bool
shouldDelete
;
GCState
(
GCResults
&
results_
)
:
results
(
results_
),
bytesInvalidated
(
0
)
{
}
...
...
@@ -428,16 +429,23 @@ void LocalStore::deletePathRecursive(GCState & state, const Path & path)
not holding the global GC lock) we can delete the path without
being afraid that the path has become alive again. Otherwise
delete it right away. */
if
(
S_ISDIR
(
st
.
st_mode
))
{
if
(
state
.
moveToTrash
&&
S_ISDIR
(
st
.
st_mode
))
{
// Estimate the amount freed using the narSize field. FIXME:
// if the path was not valid, need to determine the actual
// size.
state
.
bytesInvalidated
+=
size
;
if
(
chmod
(
path
.
c_str
(),
st
.
st_mode
|
S_IWUSR
)
==
-
1
)
throw
SysError
(
format
(
"making ‘%1%’ writable"
)
%
path
);
Path
tmp
=
state
.
trashDir
+
"/"
+
baseNameOf
(
path
);
if
(
rename
(
path
.
c_str
(),
tmp
.
c_str
()))
throw
SysError
(
format
(
"unable to rename ‘%1%’ to ‘%2%’"
)
%
path
%
tmp
);
try
{
if
(
chmod
(
path
.
c_str
(),
st
.
st_mode
|
S_IWUSR
)
==
-
1
)
throw
SysError
(
format
(
"making ‘%1%’ writable"
)
%
path
);
Path
tmp
=
state
.
trashDir
+
"/"
+
baseNameOf
(
path
);
if
(
rename
(
path
.
c_str
(),
tmp
.
c_str
()))
throw
SysError
(
format
(
"unable to rename ‘%1%’ to ‘%2%’"
)
%
path
%
tmp
);
state
.
bytesInvalidated
+=
size
;
}
catch
(
SysError
&
e
)
{
if
(
e
.
errNo
==
ENOSPC
)
{
printMsg
(
lvlInfo
,
format
(
"note: can't create move ‘%1%’: %2%"
)
%
path
%
e
.
msg
());
deleteGarbage
(
state
,
path
);
}
}
}
else
deleteGarbage
(
state
,
path
);
...
...
@@ -636,7 +644,14 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
if
(
state
.
shouldDelete
)
{
if
(
pathExists
(
state
.
trashDir
))
deleteGarbage
(
state
,
state
.
trashDir
);
createDirs
(
state
.
trashDir
);
try
{
createDirs
(
state
.
trashDir
);
}
catch
(
SysError
&
e
)
{
if
(
e
.
errNo
==
ENOSPC
)
{
printMsg
(
lvlInfo
,
format
(
"note: can't create trash directory: %1%"
)
%
e
.
msg
());
state
.
moveToTrash
=
false
;
}
}
}
/* Now either delete all garbage paths, or just the specified
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment