Commit graph

262 commits

Author SHA1 Message Date
Ankush Menat
766cb64d55
perf!: Cache site configs in memory for 60 seconds (#28869)
This is middle ground between caching it completely and requiring a
restart/signal to reload vs always reloading it.

I don't know any use cases that can break from this, nowhere in code
configs should be expected to reload instantly.

This change is only applied to requests for now
2024-12-27 16:21:14 +00:00
Akhil Narang
5e1146e216
fix(installer): don't set defaults for frappe.flags.root_username
Its set anyway when calling `setup_database()` (inside `get_root_connection()`)

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-12-02 13:32:06 +05:30
David
d87b786687
chore: fix all invocation of init for singledispatch -> min 1 positional arg 2024-09-13 11:53:52 +02:00
Corentin Flr
f0c7de39dc
chore(new_site): Avoid iterating None 2024-04-29 13:41:00 +02:00
King Phyte
05766680f7
fix: restoring site breaks when checking backup version (#26186)
* fix: restoring site breaks when checking backup version

The `backup_version` variable exists if and only if the `if match` branch executes, but it is used in a condition in a scope where it may not exist. Changing the variable to `match` leads to correct behaviour.

* fix: restoring site breaks when checking backup version

Co-authored-by: Akhil Narang <me@akhilnarang.dev>

* fix: version check when restoring site should be done from `match` scope

* chore: add a `return None` for better readability

No functional difference, just easier to understand/read the code.

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

---------

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
Co-authored-by: Akhil Narang <me@akhilnarang.dev>
2024-04-29 16:34:29 +05:30
Akhil Narang
0d3b2499fc
fix: don't use frappe.flags for mariadb_user_host_login_scope
This gets reset whenever we call `frappe.init()` again

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-03-29 16:57:04 +05:30
David
39d4318a27
feat: enable db socket connection 2024-03-29 10:29:50 +01:00
David
6eb1607c0a
refactor: name and explain user host login scope flag for mariadb 2024-03-29 10:26:49 +01:00
Akhil Narang
197b1ab77c
refactor(installer): use frappe.generate_hash() to generate database name
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-03-29 12:12:19 +05:30
Akhil Narang
1847e9cae8
fix: pass function as lambda
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-03-29 12:00:25 +05:30
Akhil Narang
9940868063
fix: switch to datetime.now() instead of our get_datetime()
`get_datetime()` will query the DB to get the system timezone, not something we currently have.

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-03-29 12:00:25 +05:30
Akhil Narang
4b2fde1d8f
fix: check if rollback callback is defined
Don't raise exceptions where a simple print() will suffice
Print exception before prompting for rollback

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-03-29 12:00:25 +05:30
Akhil Narang
147c0c8b37
feat: initial failed site rollback implementation
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-03-29 12:00:25 +05:30
Akhil Narang
46981622ec
feat: generate a non-deterministic database name every time - include current date in the hash
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-03-29 12:00:25 +05:30
Akhil Narang
1ffc4c7834
chore: update output to let the user know they can pass --force
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-03-29 12:00:25 +05:30
Akhil Narang
8cd23ecef5
chore: drop unused parameter
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-03-29 12:00:25 +05:30
Akhil Narang
4a43d68e52
fix: update downgrade warning
Seemed a bit confusing, https://github.com/frappe/frappe/pull/24898#discussion_r1521076386

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-03-13 11:36:00 +05:30
Akhil Narang
0576a085d7
fix(uninstall): don't allow uninstalling an app if we have other apps dependent on it
Support ticket 10929 / Sentry FRAPPE-3T8

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-03-06 13:50:00 +05:30
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +05:30
barredterra
72dca18c9e docs: imporve docstrings 2024-02-15 11:54:14 +01:00
barredterra
ee67b46d4e refactor: get_(old)_backup_version methods 2024-02-15 11:54:03 +01:00
barredterra
ed597693bb refactor: better variable name 2024-02-15 11:31:06 +01:00
barredterra
76a830574d fix: wrong operator in version check 2024-02-15 11:30:33 +01:00
Akhil Narang
26ae0f3460
fix: ruff fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-07 17:04:31 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
David Arnold
c57bc94ead
chore: cleanup frappe.connect invocations 2024-01-24 11:56:24 +01:00
David Arnold
94378b6566
chore: simplify frappe.connect and use site config for bootstrapping 2024-01-19 13:49:36 +01:00
Akhil Narang
d1906b3c16
refactor: add in a fallback to use db name as db user name
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-16 12:35:01 +05:30
Akhil Narang
c721fcf8c4
refactor: allow setting a db user name different from the database name
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-16 12:35:01 +05:30
Akhil Narang
b9923571dc
fix: check correct part of backup header
`-- Backup generated by Frappe 15.1.0 on branch fix-backup-restore`

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-08 13:06:59 +05:30
Akhil Narang
43021911ff
fix: simplify parsing version for older backups
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-12-26 11:09:08 +05:30
Akhil Narang
b010dc584f
chore(installer): fix output when prompting user about downgrade
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-12-26 11:09:08 +05:30
Akhil Narang
998f2c10d6
fix: handle older gzipped backups as well
Also fix the actual comparison

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-12-26 11:09:08 +05:30
Akhil Narang
2e382040cd
fix: simplify version detection logic
Our version detection code is relatively simple, so we shouldn't have any exceptions arising there
Just check for a None return value to decide whether we should use the older logic

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-12-26 11:09:08 +05:30
Akhil Narang
7db8baa7c4
feat(installer): drop actual gzip file extraction
Use `zgrep` to check for table name match where required

Also use a table that's at the top of the dump files (`__Auth`)

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-12-26 11:09:07 +05:30
Akhil Narang
3b0f6de883
perf: don't extract backup files unless required
Read from the gzipped file wherever possible

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-12-26 11:08:48 +05:30
Hussain Nagaria
8d2137c265 docs: consistent doc strings 2023-12-18 18:27:39 +05:30
barredterra
c35476256f refactor: simplify conditional logic
Command: `sourcery review --fix --enable de-morgan .`
2023-12-05 11:14:41 +01:00
Ankush Menat
1e20820846
refactor: Indicate that weak hash functions are not usedforsecurity (#23540)
[skip ci]
2023-12-01 16:04:37 +05:30
David Arnold
0dc2a9c2f3
refactor: normalize function signature 2023-11-10 15:12:59 +01:00
David Arnold
b2f9ff09aa
feat(db): boostrap only option if resource management is exogenous
The database resource management including privileges granting can be
done by external secops. It can be undesirable to grant the grant option
to the framework user.

This commit implements the possibility to remove user resource
management from frappe entirely and only boostrap the database with its
target user.
2023-11-09 17:11:39 +01:00
gavin
9b112b3e03
fix(cli): Use mysql CLI as fallback is mariadb isnt found (#23006) 2023-10-30 15:39:36 +00:00
Akhil Narang
091ebdd8dc
refactor(treewide): use mariadb commands directly instead of mysql (#22620)
This has been done because the mysql command issues a deprecation warning now

mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-10-10 12:49:16 +05:30
Ankush Menat
e4a6016f83 fix!: don't force all dependencies to be reinstalled
When you reinstall app forcefully all dependencies will also get
forcefully reinstalled. This IMO isn't required in most cases and can
even be breaking.

Anyway if required those apps can be manually force installed.
2023-08-23 18:05:10 +05:30
David Arnold
6b2bb9a2ab
fix: add env overrides for service orchestration (#21577)
This avoids having to manipulate config files in brittle bash
entrypoints that need to react to dynamic service discovery.

This significantly improves the operability of various bench sites.
2023-07-14 11:39:01 +05:30
Ankush Menat
ae8ee5064c refactor!: Remove error snapshot 2023-06-28 10:59:51 +05:30
Rucha Mahabal
ba8f97e789 feat: before/after hooks for any app install/uninstall 2023-06-22 16:07:06 +05:30
Gavin D'souza
d357af1533 refactor: Add a maxsplit limit to string splits 2023-01-24 19:22:51 +05:30
Richard Case
e80c8ac862
fix: improved installed app fail feedback (#19668) 2023-01-20 13:02:09 +05:30
Ankush Menat
442ba5dbf2
fix: set-config -g (#19217)
This isn't working because it uses update_site_config command which
attemts to find site_dir to create a lock which doesn't work when site
isn't init-ed.
2022-12-09 11:10:09 +05:30