-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Viewmanager.py: add check disk space #1212
Conversation
1. Old menu changed: Database Processing > Family Tree Processing Compare and Merge... > Merge... 2. Add string "The function ".
1. Capitalize all first letter "семейное древо" > "Семейное древо", 2. Old words from Tips.xml: Database Processing > Family Tree Processing Compare and Merge... > Merge... 3. Change: "Местоположение" > "Место" "граф" > "график" 4. Other small fix.
This looks like a duplicate of #1211 - wrong branch? |
Codecov Report
@@ Coverage Diff @@
## master #1212 +/- ##
=======================================
Coverage 41.16% 41.16%
=======================================
Files 1062 1062
Lines 144695 144695
=======================================
Hits 59564 59564
Misses 85131 85131 Continue to review full report at Codecov.
|
Sorry, GitHub add all my previous PRs to last PR. Alltime. Oh, GitHub not include .py files in this PR... |
@PushKK You probably just need to rebase your branches on master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. It just needs a little refinement.
@@ -580,10 +580,47 @@ def no_del_event(self, *obj): | |||
hits 'x' multiple times. """ | |||
return True | |||
|
|||
def checkdisk(self, dbfolder): # TODO check this function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This belongs in gramps/gen/utils/file.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, in new PR this function move to file.py.
""" | ||
Check disk space | ||
""" | ||
if win(): # for windows: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should we do for Windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gramps work in Windows too. it's draft for Windows. I check this code in my Linux system, but I have not Windows.
if (self.checkdisk(config.get('database.path')) < diskspace): | ||
self.uistate.push_message(self.dbstate, _("Disk space < " + str(diskspace) + " MB. Quit impossible. Clear your disk and repeat this operation.")) | ||
WarningDialog( | ||
_("Message for user:"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps "Low disk space" instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, of course.
For me - after this message I must run BleachBit and clear disk.
Gramps wait me and not freeze.
# - every backup (we need space 'last_backup_file_size'+ 5%) | ||
diskspace = 20 # Disk space for Linux - 20 MB, for Gramps - 5 MB, for backup 'last_backup_file_size' + 5% | ||
if (self.checkdisk(config.get('database.path')) < diskspace): | ||
self.uistate.push_message(self.dbstate, _("Disk space < " + str(diskspace) + " MB. Quit impossible. Clear your disk and repeat this operation.")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use format strings instead of concatenation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not Python man.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrite this code. New PR have normal string concatenation.
I check code, all translated strings are present in .po file.
if os.path.isfile(os.path.join(path, bfile)) and bfile.startswith(backup_name) and bfile.endswith(backup_ext): | ||
blastfile = bfile | ||
|
||
bfile_size = round(os.path.getsize(os.path.join(path, blastfile))/(1024)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A utility function to return the largest backup size would be neater.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think about this - we must use biggest or last backup file.
In result - Gramps must use last backup file for active database.
Reason:
If user delete non used info from database -> new_database_size < old_database_size.
And Gramps create new_database_backup with small size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It just needs to be put into a utility function in gramps/gen/utils/file.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I test this code two day.
In result - backup_file_size must be calculated from active_database_size.
For SQLite3 - database with testdata have 71 MB, backup have 4,1 MB file (> 7%).
If user create new Family tree and import to tree data from other base - Gramps must say to user:
- You need least 'calculated backup_file_size' MB
or (easy way on 'try - except') - You cannot save your file. Clear your disk and try save again.
Replaced by PR #1218. |
1 similar comment
Replaced by PR #1218. |
For https://gramps-project.org/bugs/view.php?id=12306
I add check disk space before Quit and BackUp.
Test this code please.