Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
auto-tx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vamp
auto-tx
Commits
3af8ad75
Commit
3af8ad75
authored
5 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Clean up methods superseded by StorageStatus class
Relates to
#20
parent
25a3f9a7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ATxCommon/FsUtils.cs
+0
-62
0 additions, 62 deletions
ATxCommon/FsUtils.cs
with
0 additions
and
62 deletions
ATxCommon/FsUtils.cs
+
0
−
62
View file @
3af8ad75
using
System
;
using
System.Collections.Generic
;
using
System.Globalization
;
using
System.IO
;
using
System.Linq
;
...
...
@@ -88,67 +87,6 @@ namespace ATxCommon
return
(
baseTime
-
dirTimestamp
).
Days
;
}
/// <summary>
/// Assemble a dictionary with information about expired directories.
/// </summary>
/// <param name="baseDir">The base directory to scan for subdirectories.</param>
/// <param name="thresh">The number of days used as expiration threshold.</param>
/// <returns>A dictionary having usernames as keys (of those users that actually do have
/// expired directories), where the values are lists of tuples with the DirInfo objects,
/// size (in bytes) and age (in days) of the expired directories.</returns>
public
static
Dictionary
<
string
,
List
<
Tuple
<
DirectoryInfo
,
long
,
int
>>>
ExpiredDirs
(
DirectoryInfo
baseDir
,
int
thresh
)
{
var
collection
=
new
Dictionary
<
string
,
List
<
Tuple
<
DirectoryInfo
,
long
,
int
>>>();
var
now
=
DateTime
.
Now
;
foreach
(
var
userdir
in
baseDir
.
GetDirectories
())
{
var
expired
=
new
List
<
Tuple
<
DirectoryInfo
,
long
,
int
>>();
foreach
(
var
subdir
in
userdir
.
GetDirectories
())
{
var
age
=
DirNameToAge
(
subdir
,
now
);
if
(
age
<
thresh
)
continue
;
long
size
=
-
1
;
try
{
size
=
GetDirectorySize
(
subdir
.
FullName
);
}
catch
(
Exception
ex
)
{
Log
.
Error
(
"ERROR getting directory size of [{0}]: {1}"
,
subdir
.
FullName
,
ex
.
Message
);
}
expired
.
Add
(
new
Tuple
<
DirectoryInfo
,
long
,
int
>(
subdir
,
size
,
age
));
}
if
(
expired
.
Count
>
0
)
collection
.
Add
(
userdir
.
Name
,
expired
);
}
return
collection
;
}
/// <summary>
/// Generate a report on expired folders in the grace location.
///
/// Check all user-directories in the grace location for subdirectories whose timestamp
/// (the directory name) exceeds the configured grace period and generate a summary
/// containing the age and size of those directories.
/// </summary>
/// <param name="graceLocation">The location to scan for expired folders.</param>
/// <param name="threshold">The number of days used as expiration threshold.</param>
public
static
string
GraceLocationSummary
(
DirectoryInfo
graceLocation
,
int
threshold
)
{
var
expired
=
ExpiredDirs
(
graceLocation
,
threshold
);
var
report
=
""
;
foreach
(
var
userdir
in
expired
.
Keys
)
{
report
+=
"\n - user '"
+
userdir
+
"'\n"
;
foreach
(
var
subdir
in
expired
[
userdir
])
{
report
+=
string
.
Format
(
" - {0} [age: {2}, size: {1}]\n"
,
subdir
.
Item1
,
Conv
.
BytesToString
(
subdir
.
Item2
),
TimeUtils
.
DaysToHuman
(
subdir
.
Item3
));
}
}
if
(
string
.
IsNullOrEmpty
(
report
))
return
""
;
return
"Expired folders in grace location:\n"
+
report
;
}
/// <summary>
/// Check if a given directory is empty. If a marker file is set in the config a
/// file with this name will be created inside the given directory and will be
...
...
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