Starting sugar-activity inside Terminal gives bad value for get_activity_root()
quozl opened this issue · 12 comments
Reproducer:
- start Terminal,
- check the contents of the Terminal activity data directory,
/home/$USER/.sugar/default/org.laptop.Terminal/data
, and note nogecko
directory orplaces.db
file, - change directory to the Browse activity sources,
- type
sugar-activity
to start the Browse activity, - stop the Browse activity,
- check the contents of the Terminal activity data directory,
/home/$USER/.sugar/default/org.laptop.Terminal/data
,
Expected result: no new files in the Terminal activity data directory.
Observed result: gecko
directory or places.db
file created by Browse in the Terminal activity data directory.
@quozl I would like to work on this issue. I am unsure what the issue exactly demands. Should the gecko directory and places.db never be generated while starting the Browse Activity or is it that the files should not exist only when the Browse Activity is started and stopped without any work being done?
@aarjavjain1, thanks, I've edited the expected result, adding "in the Terminal activity data directory". The issue demands that starting sugar-activity
inside Terminal does not give an activity a bad value return by the function get_activity_root
. In turn this may be because the shell process created by Vte in the Terminal activity has inherited several environment variables that were given to the Terminal activity by sugar-activity
. Cleaning the environment of these variables may be a fix.
@quozl What I am thinking is that while stopping the Browse Activity, we can delete the gecko directory and places.db after which the files will be created but will be deleted as soon as the Browse Activity is stopped. If I go ahead with this approach, I will have to make changes to webactivity.py in the Browse Activity. I can not find the code to Browse Activity in this repository. Is this a right approach or am I missing something?
Thanks, interesting, never thought of that. But wrong approach, and yes you're missing something.
Firstly, if you do that, then user history of browsing will be lost, which is a regression.
Secondly, you would have to do it to every one of hundreds of activities that create files in their activity data directory, and force them to lose the ability to use that directory. That would be a major project-wide regression.
I don't know what you're missing. Try again.
@quozl thanks for bearing with me.
I understand the consequences of deleting the files, but the issue demands that there should not be any files in the Terminal activity data directory.
Please correct me if I am wrong, but this implies that the data in those files is relevant. Does that mean the files created are important and they should exist in the Browse activity data directory instead of Terminal activity data directory?
Also, what exactly do you want to infer by cleaning the environment of the variables.
The files are there by accident, only when using Terminal, because the environment variables are not cleaned.
@quozl I have a solution for this issue.
When the browse activity is called, we can check whether if call is coming from the Terminal Activity. If it is so, then we can change the environment variables so that the files are generated at the appropriate location.
For this, we will have to make changes in https://github.com/sugarlabs/browse-activity
I have locally tested these changes as well. Should I make a pull request in browse-activity repository or am I supposed to do something else.
It would only fix it for the Browse activity. Other activities would be affected. The problem is caused by the Terminal activity. Why not fix it in the Terminal activity? Or the toolkit?
Developers testing activities from git clones, that's all. Benefits are immediate feedback without having to look at logs. Side-effects are such as this, and inability to join a shared activity.
@quozl I have another solution for this.
In the function get_activity_root
we can replace 'org.laptop.Terminal' with the current SUGAR_BUNDLE_ID
in the environment variable SUGAR_ACTIVITY_ROOT
.
This way, if the activity call is from Terminal, it gets replaced by the activity that is currently going on. If the activity called is Terminal, it remains the same.
I have tried the code and it works fine for me locally. The only problem is with the Pippy Activity as it used the data and instance directory of the Terminal activity folder due to which I have made the directories in the get_activity_root function so that the activity makes it's own file and uses them.
Please let me know what you think about it.