Skip to content

Commit

Permalink
feat(backup): save backup file before sending to destinations
Browse files Browse the repository at this point in the history
closes #266
  • Loading branch information
christopherpickering committed Oct 25, 2022
1 parent e5bd0d7 commit 9023efb
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 47 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules/*
web/static/lib/*
web/static/fonts/*
web/static/css/*
.lighthouserc/*
2 changes: 0 additions & 2 deletions runner/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ class ConnectionSftp(db.Model):
username: Optional[str] = None
key: Optional[str] = None
password: Optional[str] = None
task: Optional[str] = None

id = db.Column(db.Integer, primary_key=True, index=True)
connection_id = db.Column(
Expand Down Expand Up @@ -482,7 +481,6 @@ class ConnectionFtp(db.Model):
path: Optional[str] = None
username: Optional[str] = None
password: Optional[str] = None
task: Optional[str] = None

id = db.Column(db.Integer, primary_key=True, index=True)
connection_id = db.Column(
Expand Down
2 changes: 1 addition & 1 deletion runner/scripts/em_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __load(self) -> Tuple[Dict[Any, Any], Dict[Any, Any]]:
project_params = self.__parse_params(self.task.project.params)

if self.task.params:
task_params = self.__parse_params(self.task.params)
task_params = self.__parse_params(self.task.params) # type: ignore

return project_params, task_params

Expand Down
42 changes: 21 additions & 21 deletions runner/scripts/task_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,27 @@ def __store_files(self) -> None:
f"Storing file {file_counter} of {len(self.source_files)}...",
)
# store
# save historical copy
smb_path = Smb(
task=self.task,
run_id=self.run_id,
connection=None, # "default",
directory=self.temp_path,
).save(overwrite=1, file_name=file_name)

# log file details
db.session.add(
TaskFile(
name=file_name,
path=smb_path,
task_id=self.task.id,
job_id=self.run_id,
file_hash=file_hash,
size=file_size(str(os.path.getsize(file_path))),
)
)
db.session.commit()

# send to sftp
if self.task.destination_sftp == 1 and self.task.destination_sftp_conn:
if (
Expand Down Expand Up @@ -705,27 +726,6 @@ def __store_files(self) -> None:
file_name=file_name,
)

# save historical copy
smb_path = Smb(
task=self.task,
run_id=self.run_id,
connection=None, # "default",
directory=self.temp_path,
).save(overwrite=1, file_name=file_name)

# log file details
db.session.add(
TaskFile(
name=file_name,
path=smb_path,
task_id=self.task.id,
job_id=self.run_id,
file_hash=file_hash,
size=file_size(str(os.path.getsize(file_path))),
)
)
db.session.commit()

def __send_email(self) -> None:

logs = (
Expand Down
2 changes: 0 additions & 2 deletions scheduler/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ class ConnectionSftp(db.Model):
username: Optional[str] = None
key: Optional[str] = None
password: Optional[str] = None
task: Optional[str] = None

id = db.Column(db.Integer, primary_key=True, index=True)
connection_id = db.Column(
Expand Down Expand Up @@ -482,7 +481,6 @@ class ConnectionFtp(db.Model):
path: Optional[str] = None
username: Optional[str] = None
password: Optional[str] = None
task: Optional[str] = None

id = db.Column(db.Integer, primary_key=True, index=True)
connection_id = db.Column(
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ ignore_errors = True
[mypy-*.ldap_auth]
ignore_errors = True

[mypy-*.model]
disable_error_code = name-defined

[flake8]
max-line-length = 99
per-file-ignores =
Expand Down
2 changes: 0 additions & 2 deletions web/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ class ConnectionSftp(db.Model):
username: Optional[str] = None
key: Optional[str] = None
password: Optional[str] = None
task: Optional[str] = None

id = db.Column(db.Integer, primary_key=True, index=True)
connection_id = db.Column(
Expand Down Expand Up @@ -482,7 +481,6 @@ class ConnectionFtp(db.Model):
path: Optional[str] = None
username: Optional[str] = None
password: Optional[str] = None
task: Optional[str] = None

id = db.Column(db.Integer, primary_key=True, index=True)
connection_id = db.Column(
Expand Down
2 changes: 1 addition & 1 deletion web/static/fonts/inter/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"defSubset": "latin",
"fontId": "inter",
"fontName": "Inter",
"lastModified": "2022-07-12",
"lastModified": "2022-09-22",
"license": "https://fonts.google.com/attribution",
"source": "https://fonts.google.com/",
"styles": [
Expand Down
2 changes: 1 addition & 1 deletion web/static/fonts/inter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"type": "git",
"url": "https://github.com/fontsource/fontsource.git"
},
"version": "4.5.12"
"version": "4.5.14"
}
10 changes: 1 addition & 9 deletions web/static/fonts/rasa/files/file-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,5 @@
"./fonts/google/rasa/files/rasa-gujarati-variable-wghtOnly-italic.woff2",
"./fonts/google/rasa/files/rasa-vietnamese-variable-wghtOnly-italic.woff2",
"./fonts/google/rasa/files/rasa-latin-ext-variable-wghtOnly-italic.woff2",
"./fonts/google/rasa/files/rasa-latin-variable-wghtOnly-italic.woff2",
"./fonts/google/rasa/files/rasa-gujarati-variable-full-normal.woff2",
"./fonts/google/rasa/files/rasa-vietnamese-variable-full-normal.woff2",
"./fonts/google/rasa/files/rasa-latin-ext-variable-full-normal.woff2",
"./fonts/google/rasa/files/rasa-latin-variable-full-normal.woff2",
"./fonts/google/rasa/files/rasa-gujarati-variable-full-italic.woff2",
"./fonts/google/rasa/files/rasa-vietnamese-variable-full-italic.woff2",
"./fonts/google/rasa/files/rasa-latin-ext-variable-full-italic.woff2",
"./fonts/google/rasa/files/rasa-latin-variable-full-italic.woff2"
"./fonts/google/rasa/files/rasa-latin-variable-wghtOnly-italic.woff2"
]
2 changes: 1 addition & 1 deletion web/static/fonts/rasa/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"defSubset": "latin",
"fontId": "rasa",
"fontName": "Rasa",
"lastModified": "2022-07-19",
"lastModified": "2022-09-22",
"license": "https://fonts.google.com/attribution",
"source": "https://fonts.google.com/",
"styles": [
Expand Down
2 changes: 1 addition & 1 deletion web/static/fonts/rasa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"type": "git",
"url": "https://github.com/fontsource/fontsource.git"
},
"version": "4.5.12"
"version": "4.5.13"
}
4 changes: 2 additions & 2 deletions web/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
var q = new XMLHttpRequest();

searchResultsContainer = document.getElementById('search-results');
if (!searchResultsContainer){
return !1;
if (!searchResultsContainer) {
return !1;
}

// if data exists in localstorage, then enable search immediately.
Expand Down
8 changes: 4 additions & 4 deletions web/web/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,15 +879,15 @@ def task_log(task_id: int) -> Response:
me.append({"empty_msg": "No log messages."})

if request.args.get("gte"):
logs = logs.filter(TaskLog.id >= request.args["gte"]).all()
logs = logs.filter(TaskLog.id >= request.args["gte"])

elif request.args.get("lt"):
logs = logs.filter(TaskLog.id < request.args["lt"]).limit(40).all()
logs = logs.filter(TaskLog.id < request.args["lt"]).limit(40)

else:
logs = logs.limit(40).offset(0).all()
logs = logs.limit(40).offset(0)

for log in logs:
for log in logs.all():

log = dict(zip(cols.keys(), log))

Expand Down

0 comments on commit 9023efb

Please sign in to comment.