a
This commit is contained in:
parent
eaa3c01cc4
commit
087c5b6213
5 changed files with 23 additions and 18 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,3 @@
|
|||
.env
|
||||
.idea/
|
||||
.vscode/
|
||||
etcd3_wrapper
|
||||
|
|
0
.gitmodules
vendored
0
.gitmodules
vendored
5
Pipfile
5
Pipfile
|
@ -8,8 +8,7 @@ verify_ssl = true
|
|||
[packages]
|
||||
python-decouple = "*"
|
||||
xattr = "*"
|
||||
grpcio = "*"
|
||||
etcd3 = "*"
|
||||
etcd3-wrapper = "*"
|
||||
|
||||
[requires]
|
||||
python_version = "3.7"
|
||||
python_version = "3.5"
|
||||
|
|
14
Pipfile.lock
generated
14
Pipfile.lock
generated
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "22c474ecb2c9dc36027dceb71527ccb3650d8b59334b3aa49cea4351c6c8d4e9"
|
||||
"sha256": "88fae7fa71f123945ce3e7d19a17c8808d70cd457b6bfa68721ba97c1bcf8d41"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_version": "3.7"
|
||||
"python_version": "3.5"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
|
@ -53,9 +53,16 @@
|
|||
"hashes": [
|
||||
"sha256:25a524b9f032c6631ff0097532907dea81243eaa63c3744510fd1598cc4e0e87"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==0.10.0"
|
||||
},
|
||||
"etcd3-wrapper": {
|
||||
"hashes": [
|
||||
"sha256:0296a4cc7c75c6c432f54e95699271894716e99048c9987df55b6885ed9d5d07",
|
||||
"sha256:8c4e90593ea6586978f0fbd484e46fd7d8554e06cb9804d34805a1f15a046b63"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==0.5.2"
|
||||
},
|
||||
"grpcio": {
|
||||
"hashes": [
|
||||
"sha256:1303578092f1f6e4bfbc354c04ac422856c393723d3ffa032fff0f7cb5cfd693",
|
||||
|
@ -116,7 +123,6 @@
|
|||
},
|
||||
"pycparser": {
|
||||
"hashes": [
|
||||
"sha256:962841e251bcdd1c41a902584a23490ced468367ac9fa90d45f404373a230041",
|
||||
"sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3"
|
||||
],
|
||||
"version": "==2.19"
|
||||
|
|
9
main.py
9
main.py
|
@ -38,7 +38,7 @@ FILE_PREFIX = config("FILE_PREFIX")
|
|||
etcd_client = Etcd3Wrapper(host=config("ETCD_URL"))
|
||||
|
||||
# Recursively Get All Files and Folder below BASE_DIR
|
||||
files = glob.glob(f"{BASE_DIR}/**", recursive=True)
|
||||
files = glob.glob("{}/**".format(BASE_DIR), recursive=True)
|
||||
|
||||
# Retain only Files
|
||||
files = list(filter(lambda f: os.path.isfile(f), files))
|
||||
|
@ -71,15 +71,16 @@ for file in untracked_files:
|
|||
file_path = os.path.join(*file_path)
|
||||
|
||||
# Create Entry
|
||||
entry_key = f"{FILE_PREFIX}/{file_id}"
|
||||
entry_value = {"filename": file_path,
|
||||
entry_key = os.path.join(FILE_PREFIX, file_id)
|
||||
entry_value = {
|
||||
"filename": file_path,
|
||||
"owner": owner,
|
||||
"sha512sum": sha_sum,
|
||||
"creation_date": creation_date,
|
||||
"size": size
|
||||
}
|
||||
|
||||
print(f"Tracking {file}")
|
||||
print("Tracking {}".format(file))
|
||||
# Insert Entry
|
||||
etcd_client.put(entry_key, entry_value, value_in_json=True)
|
||||
xattr.setxattr(file, b"user.utracked", b"True")
|
||||
|
|
Loading…
Reference in a new issue