etesync / server

The Etebase server (so you can run your own)
https://www.etesync.com
GNU Affero General Public License v3.0
1.48k stars 75 forks source link

FileNotFoundError: [Errno 2] No such file or directory #155

Open Xeboc opened 1 year ago

Xeboc commented 1 year ago

If I sign out of the Android app, and attempt to sign back in, I receive endless file not found errors, and the Android Etesync App reports Calendar and Task sync failed.

INFO:     10.40.40.2:47438 - "GET /api/v1/collection/yC0aqctkmG1fP6L6WtgAoIBsCXKbopTD/item/ HTTP/1.1" 200 OK
INFO:     10.40.40.2:47436 - "GET /api/v1/collection/HgAHqCikBnmWDRFr3f9Wq1ict3joXG4W/item/ HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/opt/etebase/.venv/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 372, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/opt/etebase/.venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
    return await self.app(scope, receive, send)
  File "/opt/etebase/.venv/lib/python3.10/site-packages/fastapi/applications.py", line 261, in __call__
    await super().__call__(scope, receive, send)
  File "/opt/etebase/.venv/lib/python3.10/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/opt/etebase/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc
  File "/opt/etebase/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/opt/etebase/.venv/lib/python3.10/site-packages/starlette/middleware/trustedhost.py", line 51, in __call__
    await self.app(scope, receive, send)
  File "/opt/etebase/.venv/lib/python3.10/site-packages/starlette/middleware/cors.py", line 84, in __call__
    await self.app(scope, receive, send)
  File "/opt/etebase/.venv/lib/python3.10/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc
  File "/opt/etebase/.venv/lib/python3.10/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/opt/etebase/.venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/opt/etebase/.venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/opt/etebase/.venv/lib/python3.10/site-packages/starlette/routing.py", line 656, in __call__
    await route.handle(scope, receive, send)
  File "/opt/etebase/.venv/lib/python3.10/site-packages/starlette/routing.py", line 259, in handle
    await self.app(scope, receive, send)
  File "/opt/etebase/.venv/lib/python3.10/site-packages/starlette/routing.py", line 61, in app
    response = await func(request)
  File "/opt/etebase/./etebase_server/fastapi/msgpack.py", line 74, in custom_route_handler
    return await route_handler(request)
  File "/opt/etebase/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 227, in app
    raw_response = await run_endpoint_function(
  File "/opt/etebase/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 162, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/opt/etebase/.venv/lib/python3.10/site-packages/starlette/concurrency.py", line 39, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "/opt/etebase/.venv/lib/python3.10/site-packages/anyio/to_thread.py", line 28, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(func, *args, cancellable=cancellable,
  File "/opt/etebase/.venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 818, in run_sync_in_worker_thread
    return await future
  File "/opt/etebase/.venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 754, in run
    result = context.run(func, *args)
  File "/opt/etebase/./etebase_server/fastapi/db_hack.py", line 25, in wrapper
    return func(*args, **kwargs)
  File "/opt/etebase/./etebase_server/fastapi/db_hack.py", line 25, in wrapper
    return func(*args, **kwargs)
  File "/opt/etebase/./etebase_server/fastapi/routers/collection.py", line 451, in item_list
    response = item_list_common(queryset, user, stoken, limit, prefetch)
  File "/opt/etebase/./etebase_server/fastapi/routers/collection.py", line 435, in item_list_common
    data: t.List[CollectionItemOut] = [CollectionItemOut.from_orm_context(item, context) for item in result]
  File "/opt/etebase/./etebase_server/fastapi/routers/collection.py", line 435, in <listcomp>
    data: t.List[CollectionItemOut] = [CollectionItemOut.from_orm_context(item, context) for item in result]
  File "/opt/etebase/./etebase_server/fastapi/routers/collection.py", line 90, in from_orm_context
    content=CollectionItemRevisionInOut.from_orm_context(obj.content, context),
  File "/opt/etebase/./etebase_server/fastapi/routers/collection.py", line 64, in from_orm_context
    with open(chunk_obj.chunkFile.path, "rb") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/opt/etebase/media/user_3/HgAHqCikBnmWDRFr3f9Wq1ict3joXG4W/v-/UX-O64j5IbmNKdyRnubaguGEpp88Hobfej_BPLV_s'

If I mkdir -p and touch those files, the error messages just mention different files that are missing, endlessly.

Ubuntu 22.04.1, up to date. Any ideas?

elig0n commented 1 year ago

I experience the same issue when trying to sync from the Android etesync application

INFO:      - "GET /api/v1/collection/RIs3faJkSi_C9Gar7a_C_4ZFZ933El1V/item/ HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 419, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/usr/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "/usr/lib/python3.10/site-packages/fastapi/applications.py", line 270, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/lib/python3.10/site-packages/starlette/applications.py", line 124, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/usr/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/usr/lib/python3.10/site-packages/starlette/middleware/trustedhost.py", line 34, in __call__
    await self.app(scope, receive, send)
  File "/usr/lib/python3.10/site-packages/starlette/middleware/cors.py", line 84, in __call__
    await self.app(scope, receive, send)
  File "/usr/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/usr/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/usr/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/usr/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/usr/lib/python3.10/site-packages/starlette/routing.py", line 706, in __call__
    await route.handle(scope, receive, send)
  File "/usr/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/usr/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
  File "/usr/lib/python3.10/site-packages/etebase_server/fastapi/msgpack.py", line 74, in custom_route_handler
    return await route_handler(request)
  File "/usr/lib/python3.10/site-packages/fastapi/routing.py", line 231, in app
    raw_response = await run_endpoint_function(
  File "/usr/lib/python3.10/site-packages/fastapi/routing.py", line 162, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/usr/lib/python3.10/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "/usr/lib/python3.10/site-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/usr/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "/usr/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "/usr/lib/python3.10/site-packages/etebase_server/fastapi/db_hack.py", line 25, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/etebase_server/fastapi/db_hack.py", line 25, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/etebase_server/fastapi/routers/collection.py", line 451, in item_list
    response = item_list_common(queryset, user, stoken, limit, prefetch)
  File "/usr/lib/python3.10/site-packages/etebase_server/fastapi/routers/collection.py", line 435, in item_list_common
    data: t.List[CollectionItemOut] = [CollectionItemOut.from_orm_context(item, context) for item in result]
  File "/usr/lib/python3.10/site-packages/etebase_server/fastapi/routers/collection.py", line 435, in <listcomp>
    data: t.List[CollectionItemOut] = [CollectionItemOut.from_orm_context(item, context) for item in result]
  File "/usr/lib/python3.10/site-packages/etebase_server/fastapi/routers/collection.py", line 90, in from_orm_context
    content=CollectionItemRevisionInOut.from_orm_context(obj.content, context),
  File "/usr/lib/python3.10/site-packages/etebase_server/fastapi/routers/collection.py", line 64, in from_orm_context
    with open(chunk_obj.chunkFile.path, "rb") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.10/site-packages/media/user_2/RIs3faJkSi_C9Gar7a_C_4ZFZ933El1V/W7/p_oDwo7MmCivp97SvZ1Xvw7S7POwddlGehu2RItoE'
tasn commented 1 year ago

Did you delete server data behind its back? It complains that a file it expects to exist doesn't.

elig0n commented 1 year ago

Did you delete server data behind its back? It complains that a file it expects to exist doesn't.

Not that I know. Do you think an upgrade could do it ? Like from pip or AUR ?

tasn commented 1 year ago

I doubt it, but maybe. Can you try searching for p_oDwo7MmCivp97SvZ1Xvw7S7POwddlGehu2RItoE in /usr/lib/python3.10/site-packages/media/user_2?

Btw, this path is a very weird one for user-hosted media files. I think you're maybe running etesync in a weird manner.