1
Fork 0
Commit Graph

15 Commits

Author SHA1 Message Date
Lajos Koszti 1f8664d7f8
fix transaction already commited error
I encountered with the following error:

> 2023/02/05 07:33:00 /app/scanner/face_detection/face_detector.go:92 sql: transaction has already been committed or rolled back
> [0.042ms] [rows:0] SELECT * FROM `media` WHERE `media`.`id` = 823 ORDER BY `media`.`id` LIMIT 1
> 2023/02/05 07:33:00 ERROR: Error detecting faces in image (/photos/Borzsony2017/DSC_0028.NEF): sql: transaction has already been committed or rolled back

It turned out it comes from the api/routes/photos.go

I found a very similar code in album_scanner.go.
The difference I saw was that while in the single photo request the
transaction passed to the `scanner_tasks.Tasks.BeforeProcessMedia` call,
in the album_scann.go the transaction created after this call and
created from the context which returned by `BeforeProcessMedia`.

Another difference was that in the `ProcessSingleMedia` call the
`AfterProcessMedia` call was called with the same - db transaction -
context, in the album_scanner it was called outside of the transaction.

I changed the logic by merging the two behavior:
Create the transaction from the context of `BeforeProcessMedia` and also
use the transaction context in the `AfterProcessMedia`.
After the change the error disappeared.

So to have it in a common place I extracted that logic into a function
and use for both the single photo request and in the album scanner.

I did not go more deeper to find out what's going on with the context
under the hood.
2023-02-05 09:05:05 +01:00
viktorstrate b09d32019e
Make it compile again 2022-03-02 17:26:06 +01:00
viktorstrate 8e8abe7d37
Replace all gorm .Scan() calls with .Find()
if the argument is a model. This ensures that the proper gorm hooks are
called which was causing the full screen view on the Places page to
crash.

Also fixed a bug in Messages.js that caused a crash.
2021-04-15 16:27:26 +02:00
viktorstrate abb80ae425
Start on face detection 2021-02-15 17:35:28 +01:00
viktorstrate 9691572154
Fix bug causing video routes to not be found 2021-01-19 16:04:33 +01:00
viktorstrate 107da91700
Refactor handling of environment variables 2021-01-17 16:50:48 +01:00
viktorstrate 907894dda3
Merge branch 'master' into v2.0.0 2020-12-17 23:18:00 +01:00
viktorstrate 4cd822f068
Update gomod to reflect repo transfer 2020-12-17 22:51:43 +01:00
viktorstrate 2b966aa672
Replace database, mostly media and video 2020-11-26 20:48:04 +01:00
viktorstrate 27b2f95a7b Start on migrating database integration to gorm 2020-11-23 19:39:44 +01:00
viktorstrate 74581ee090 Cleanup media routes and media_name generation 2020-10-30 17:14:09 +01:00
viktorstrate 07477ea789 Remove debug log 2020-07-13 18:15:23 +02:00
viktorstrate 21f66b9e62 Use cookie based auth for shares with password 2020-07-13 17:51:53 +02:00
viktorstrate f669812efb Use cookies for authentication instead of header
This replaces the current implementation
where a bearer header holds the auth-token.
Now the same token is being sent using a cookie instead.
This greatly simplifies fetching resources (images and video),
since the header is sent along implicitly with each request.
2020-07-12 18:52:48 +02:00
viktorstrate f537b1d608 Add video route (still unprotected) 2020-07-11 15:57:58 +02:00