1
Fork 0
Commit Graph

48 Commits

Author SHA1 Message Date
WindLi001 6bebed4693 use Clean() but not Abs() to prevent directory traversal 2023-02-10 21:05:17 +08:00
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 12085698c8
Refactoring + disable cleanup tests for sqlite 2021-11-06 15:41:25 +01:00
viktorstrate c48ede175a
Fix exif circular imports in tests 2021-11-06 13:01:01 +01:00
viktorstrate d060ee9fd9
Write failing test for bug 2021-09-29 11:20:15 +02:00
viktorstrate 7799674b74
Fix album downloads when running production 2021-09-26 15:15:31 +02:00
viktorstrate 342f0a31e1
Fix API tests 2021-09-26 13:23:38 +02:00
viktorstrate 929da08ea2
Add UI for album downloads 2021-09-26 13:10:37 +02:00
viktorstrate 80c2019b3f
Protect download routes 2021-09-26 12:02:53 +02:00
viktorstrate 92662f9b8e
Start on album download 2021-09-26 00:21:02 +02:00
viktorstrate 8d2654997d
Add test for routes authenticateMedia 2021-04-26 22:35:10 +02: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 59048c8416
Fix various small errors regarding database change
- Fix media sidebar
- Fix Albums page
- Fix media and album shares
2021-01-02 23:07:44 +01:00
viktorstrate aeb05bca49
get initial scanner up and running 2020-12-22 01:14:43 +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 2903670255
Migrate album and media sharing 2020-12-17 22:29:24 +01:00
viktorstrate 4b778fbdde
Fix tests, fix photo route 2020-12-06 15:24:15 +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 c7ee506189 Improve media download
Allow downloading of media when no content-length is provided because of compression.
2020-11-16 12:40:06 +01:00
viktorstrate 74581ee090 Cleanup media routes and media_name generation 2020-10-30 17:14:09 +01:00
viktorstrate 4fe0608194 Setup cache headers for photo routes 2020-09-30 14:08:30 +02: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
viktorstrate 990a592fcc Expose media_type to graphql
- Make video thumbnail accessible from graphql
2020-07-11 14:21:10 +02:00
viktorstrate df80802cab Huge refactor: rename photo to media
To prepare for video support

Migrate database rename tables and columns:
- photo to media
- photo_url to media_url
- photo_exif to media_exif

- Update api accordingly
2020-07-10 14:26:19 +02:00
viktorstrate 3564866f41 Start on video processing 2020-07-10 12:58:11 +02:00
viktorstrate 11c3a92373 Reintregrate notifications with scanner 2020-06-23 15:13:07 +02:00
viktorstrate f6f6eb8bfa Prepare back-end for token password 2020-06-14 18:02:46 +02:00
viktorstrate 399cb295f2 Move spa handler to a separate file 2020-04-06 22:21:58 +02:00
viktorstrate 458b6fb49c Improve scanner - first scan, then process 2020-02-26 21:23:13 +01:00
viktorstrate d27c20e041 Improve stability of scanner 2020-02-23 18:00:08 +01:00
viktorstrate 39f68e4d8a Support PHOTO_CACHE env variable 2020-02-23 12:43:45 +01:00
viktorstrate b2a8fd09f9 Work towards subscriptions
- Replace chi with gorilla/mux
- Write custom CORS rules
- Start on notification subscriptions
2020-02-21 16:50:50 +01:00
viktorstrate 39dd89eec2 Secure public photos with the "public token" 2020-02-21 12:05:28 +01:00
viktorstrate fb62363cb8 Protect photos from public access 2020-02-20 17:31:41 +01:00
viktorstrate 64e702790f Make scanner generate high-res jpg
If original image format is not supported in browser
2020-02-14 13:31:44 +01:00
viktorstrate d50a15be90 Work on scanner + add launch.json for vscode 2020-02-11 23:35:35 +01:00
viktorstrate 6e72caf2f0 Improve integration with ui 2020-02-10 12:05:58 +01:00
viktorstrate d50b8034d1 Work on photo serving and processing 2020-02-09 14:21:53 +01:00
viktorstrate 9a8701ecd0 Improve image processing 2020-02-09 12:53:21 +01:00