Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
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
RadioObservatory
LOFAR
Commits
18455a5a
Commit
18455a5a
authored
9 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
Task #8291: added methods numFilesInDirectory and numFilesInTree
parent
031e9408
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
LTA/ltastorageoverview/lib/store.py
+25
-0
25 additions, 0 deletions
LTA/ltastorageoverview/lib/store.py
with
25 additions
and
0 deletions
LTA/ltastorageoverview/lib/store.py
+
25
−
0
View file @
18455a5a
...
@@ -213,6 +213,18 @@ class LTAStorageDb:
...
@@ -213,6 +213,18 @@ class LTAStorageDb:
where directory_id = ?
where directory_id = ?
'''
,
[
directory_id
]).
fetchall
()
'''
,
[
directory_id
]).
fetchall
()
def
numFilesInDirectory
(
self
,
directory_id
):
with
sqlite3
.
connect
(
self
.
db_filename
)
as
conn
:
result
=
conn
.
execute
(
'''
SELECT count(id) FROM fileinfo
where directory_id = ?
'''
,
[
directory_id
]).
fetchone
()
if
result
:
return
result
[
0
]
return
0
def
filesInTree
(
self
,
base_directory_id
):
def
filesInTree
(
self
,
base_directory_id
):
with
sqlite3
.
connect
(
self
.
db_filename
)
as
conn
:
with
sqlite3
.
connect
(
self
.
db_filename
)
as
conn
:
return
conn
.
execute
(
'''
return
conn
.
execute
(
'''
...
@@ -222,6 +234,19 @@ class LTAStorageDb:
...
@@ -222,6 +234,19 @@ class LTAStorageDb:
where dc.ancestor_id = ?
where dc.ancestor_id = ?
'''
,
[
base_directory_id
]).
fetchall
()
'''
,
[
base_directory_id
]).
fetchall
()
def
numFilesInTree
(
self
,
base_directory_id
):
with
sqlite3
.
connect
(
self
.
db_filename
)
as
conn
:
result
=
conn
.
execute
(
'''
SELECT count(fileinfo.id) FROM directory_closure dc
join fileinfo on fileinfo.directory_id = dc.descendant_id
where dc.ancestor_id = ?
'''
,
[
base_directory_id
]).
fetchone
()
if
result
:
return
result
[
0
]
return
0
def
totalFileSizeInTree
(
self
,
base_directory_id
):
def
totalFileSizeInTree
(
self
,
base_directory_id
):
with
sqlite3
.
connect
(
self
.
db_filename
)
as
conn
:
with
sqlite3
.
connect
(
self
.
db_filename
)
as
conn
:
result
=
conn
.
execute
(
'''
result
=
conn
.
execute
(
'''
...
...
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