-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Change the working directory if we can't stat it #6559
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
Change the working directory if we can't stat it #6559
Conversation
OK this is now working but it's not excellent as it doesn't inform us that we are moving a temporary directory. This needs to be logged somehow but will require thought - for example - we can't log from gitea serv as this would break git. |
Codecov Report
@@ Coverage Diff @@
## master #6559 +/- ##
=======================================
Coverage 41.49% 41.49%
=======================================
Files 440 440
Lines 59453 59453
=======================================
Hits 24671 24671
Misses 31564 31564
Partials 3218 3218 Continue to review full report at Codecov.
|
Does it make sense for this code to run all of the time? If somebody runs If not, could it just be run based on os.Args and only run for certain commands where using a temporary work dir makes sense, like I assume it isn't reasonable to have gitea configured to run from a place without proper permissions and have things like web and srv working, where as the initial bug report case is more reasonable to expect |
@mrsdizzie You don't get that choice - this has to run at package init() time, and has to run before macaron.v1's package init runs. That means when it runs you don't know what command you're going to run. |
We could however, detect that we're running from the temporary directory for some commands and fail because we can't run from there with a different Before for those that need it. |
An alternative option is to delete the working directory at the start of main. Then if anything tries to write or read from the working directory it will fail - albeit with the incorrect error: "no such file or directory" instead of "permission denied" @mrsdizzie @lunny Would that be preferable? |
Codecov Report
@@ Coverage Diff @@
## master #6559 +/- ##
==========================================
- Coverage 40.37% 40.34% -0.03%
==========================================
Files 405 406 +1
Lines 54260 54289 +29
==========================================
- Hits 21907 21905 -2
- Misses 29337 29366 +29
- Partials 3016 3018 +2
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #6559 +/- ##
==========================================
- Coverage 40.37% 40.35% -0.02%
==========================================
Files 405 406 +1
Lines 54260 54289 +29
==========================================
+ Hits 21907 21910 +3
- Misses 29337 29361 +24
- Partials 3016 3018 +2
Continue to review full report at Codecov.
|
95430ca
to
1f84970
Compare
Attempt to change the working directory if we can't stat it. This hopefully runs before the macaron init but may need to be moved to a file called a.go
Fix #4634