Skip to content
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

Check if Include folders/files do exists (in case they are removed) #1718

Draft
wants to merge 15 commits into
base: dev
Choose a base branch
from

Conversation

rafaelhdr
Copy link
Contributor

Solution b) when start taking a snapshot the include list should be checked of existence first and warn about missings.

reference: #1586

Solution b) when start taking a snapshot the include list should be checked of existence first and warn about missings.

reference: bit-team#1586
@rafaelhdr
Copy link
Contributor Author

rafaelhdr commented May 9, 2024

This is not complete yet, but if possible I would like some feedback before finishing it.

Are the messages good? And I am wondering if the qt warning is ok (it is asking a confirmation before continuing instead of just warning).

And I didn't implement a) for no big reason. I am still getting familiar with the code and b) was something that was more clear for me. I could try a) in a future PR.

And how you normally do translations? I was planning to translate all other languages using some automated tool (Copilot) but I wanted to confirm how you guys do it normally...

CHANGES Outdated Show resolved Hide resolved
common/backintime.py Outdated Show resolved Hide resolved
common/backintime.py Outdated Show resolved Hide resolved
common/backintime.py Outdated Show resolved Hide resolved
common/po/pt_BR.po Outdated Show resolved Hide resolved
common/snapshots.py Outdated Show resolved Hide resolved
qt/app.py Show resolved Hide resolved
qt/app.py Outdated Show resolved Hide resolved
qt/app.py Outdated Show resolved Hide resolved
@buhtz
Copy link
Member

buhtz commented May 9, 2024

Dear Rafael,
Awesome! Thank you for this next contribution.

I added some comments and suggestions to the code. I am not sure about the whole solution. I would suggest to further discuss it in the related issue #1586.

I will set the PR into Draft mode to state the the solution is not finished.

Best,
Christian

rafaelhdr and others added 4 commits May 9, 2024 22:19
Co-authored-by: buhtz <c.buhtz@posteo.jp>
Co-authored-by: buhtz <c.buhtz@posteo.jp>
Co-authored-by: buhtz <c.buhtz@posteo.jp>
Co-authored-by: buhtz <c.buhtz@posteo.jp>
@rafaelhdr
Copy link
Contributor Author

I appreciate a lot for the review. It clarified a lot of questions and taught me some good lessons (I would never have thought about RTL issues on translations). And I am happy about not use the camel case :)

I will do the fixes from the review and wait for any suggestion in the original issue.

Thank you very much 🙏

@buhtz
Copy link
Member

buhtz commented May 10, 2024

Does anyone know how to trigger the systray-icon message-bubbles via BIT?

I tried with "Snapshot.setTakeSnapshotMessage(1, 'FOO BAR')" but without success. This message appears in the status bar of the main window.

@buhtz
Copy link
Member

buhtz commented May 12, 2024

I would never have thought about RTL issues on translations

Me neither. When I started to work on the translation task I thougt it is easy. I learned things like that from translators and the community around them while trying to attract translators to BIT.

@buhtz buhtz added Discussion decision or consensus needed PR: Waiting for review PR won't be merged until review and approval from a member of the maintenance team. labels May 13, 2024
@rafaelhdr
Copy link
Contributor Author

I am still checking on Systray. TBH I didn't know we had a systray (it is not running fine here). But I will keep trying to understand it in order to make the fix.

@aryoda
Copy link
Contributor

aryoda commented May 13, 2024

Does anyone know how to trigger the systray-icon message-bubbles via BIT?

Our systray icon started as stand-alone process

def processBegin(self):
try:
logger.debug("Trying to start systray icon sub process...")
path = os.path.join(tools.backintimePath('qt'), 'qtsystrayicon.py')
cmd = [sys.executable, path, self.snapshots.config.currentProfile()]
if logger.DEBUG:
cmd.append("--debug") # HACK to propagate DEBUG logging level to sub process
self.process = subprocess.Popen(cmd)

and it calls every second a function to update the status:

def updateInfo(self):
# Exit this systray icon "app" when the snapshots is taken
if not self.snapshots.busy():
self.prepareExit()
self.qapp.exit(0)
return
paused = tools.processPaused(self.snapshots.pid())
self.btnPause.setVisible(not paused)
self.btnResume.setVisible(paused)
message = self.snapshots.takeSnapshotMessage()
if message is None and self.last_message is None:
message = (0, _('Working…'))
if not message is None:
if message != self.last_message:
self.last_message = message
if self.decode:
message = (message[0], self.decode.log(message[1]))
self.menuStatusMessage.setText('\n'.join(textwrap.wrap(message[1], \
width = 80) \
))
self.status_icon.setToolTip(message[1])
pg = progress.ProgressFile(self.config)
if pg.fileReadable():
pg.load()
percent = pg.intValue('percent')
## disable progressbar in icon until BiT has it's own icon
## fixes bug #902
# if percent != self.progressBar.value():
# self.progressBar.setValue(percent)
# self.progressBar.render(self.pixmap, sourceRegion = QRegion(0, -14, 24, 6), flags = QWidget.RenderFlags(QWidget.DrawChildren))
# self.status_icon.setIcon(QIcon(self.pixmap))
self.menuProgress.setText(' | '.join(self.getMenuProgress(pg)))
self.menuProgress.setVisible(True)
else:
# self.status_icon.setIcon(self.icon.BIT_LOGO)
self.menuProgress.setVisible(False)

It reads the current "snapshot message" from a file:

def takeSnapshotMessage(self):

So to change the status message of the systray icon the message file's content must be changed, I guess (= not tried) with:

def setTakeSnapshotMessage(self, type_id, message, timeout=-1):

I tried with "Snapshot.setTakeSnapshotMessage(1, 'FOO BAR')" but without success. This message appears in the status bar of the main window.

The message is only shown while a snapshot is taken otherwise the systray icon is closed again (it is not running permanently - which is what I would implement in the future to also get rid of the root systray icon issues due to hijacking the X11 session of a user).

@aryoda
Copy link
Contributor

aryoda commented May 13, 2024

@rafaelhdr Thanks a lot for your contribution and helping us to improve BiT!

@rafaelhdr @buhtz I am wondering if the validation logic to check for existing includes does really work in every scenario, esp. when the include path is mounted via a user-callback the validation is only possible (valid ;-) after the user-callback is called.

I know this a quite rare scenario (using a user-callback as well as mounting the include folder - normally I mount the target folder - not the includes root folder) but we should test this before merging the PR.

For a simple user-callback example see https://github.com/bit-team/user-callback/blob/master/user-callback.diagnostics

The BiT function to mount for using a profile is this:

def mount(self, profileID = None):

@buhtz
Copy link
Member

buhtz commented May 14, 2024

I do see. This is a longer story.

@aryoda
Copy link
Contributor

aryoda commented May 14, 2024

BTW: I think to correctly test the mount/unmount user-callback calls via the BiT GUI my old patch must be applied:

#724 (comment)

Perhaps it is time to push this patch now as work-around (even though it is in-efficient because it mounts/unmounts far too often)...

@buhtz
Copy link
Member

buhtz commented May 14, 2024

@rafaelhdr @buhtz I am wondering if the validation logic to check for existing includes does really work in every scenario, esp. when the include path is mounted via a user-callback the validation is only possible (valid ;-) after the user-callback is called.

You mean if the "backup source" is an external drive for example and present all the time?
So the check should be done after the user-callback script was executed?

@aryoda
Copy link
Contributor

aryoda commented May 14, 2024

@rafaelhdr @buhtz I am wondering if the validation logic to check for existing includes does really work in every scenario, esp. when the include path is mounted via a user-callback the validation is only possible (valid ;-) after the user-callback is called.

You mean if the "backup source" is an external drive for example and present all the time? So the check should be done after the user-callback script was executed?

Yes, check for existing include folders after the user-callback script was called to "mount" everything.
An external drive would be one scenario but more realistically a network drive (if the source is not permanently mounted but only mounted for BiT and after the backup unmounted again).

Or another example: The source is an encrypted container (TrueCrypt/VeraCrypt) and shall be mounted only for backups

@rafaelhdr
Copy link
Contributor Author

Thank you for all your help, guys 🙏

About the Systray, I think I got the idea. I was able to run it locally, and I will try to add something.Thank you for the directions.

BTW, I just noticed the systray after you guys mentioned it. I was able to make it work after adding an extension to Gnome (https://extensions.gnome.org/extension/615/appindicator-support/). Do you think it is worth mentioning in the docs?

About the user-callback suggestion, I think I got it... Just to be sure, these are the logs from my local tests:

$ backintime backup --profile-id 4

> Back In Time
> Version: 1.4.4-dev.7472f54d

(...)

> WARNING: The following folders are missing: /home/rafaelhdr/Mocks2
> INFO: Lock
> INFO: Mountpoint /home/rafaelhdr/.local/share/backintime/mnt/7AE1B8E6/mountpoint is already mounted
> INFO: Take a new snapshot. Profile: 4 khadas 2
(...)

So, this WARNING: The following (...) should be happening after the INFO: Mountpoint /home/(...), right? With that, we could be sure it is properly mounted...

@rafaelhdr
Copy link
Contributor Author

Hey guys,

Thank you for all the support. I was able to display the error with this:

Screenshot from 2024-05-20 17-53-34

We could consider it as an error, right? (if not, I could replace the 1 here self.setTakeSnapshotMessage(1, msg))

And I moved the check for after the mount. I hope it is good.

Let me know if you think we could change it, but also feel free to change anything :)

@aryoda
Copy link
Contributor

aryoda commented May 20, 2024

FYI: I am AFK for one week and will review this PR when I am back...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion decision or consensus needed PR: Waiting for review PR won't be merged until review and approval from a member of the maintenance team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants