Skip to content

Commit 066b91d

Browse files
authored
Merge branch 'main' into fix/to_gif
2 parents 5f100ef + fabe8ea commit 066b91d

File tree

4 files changed

+44
-13
lines changed

4 files changed

+44
-13
lines changed

.github/workflows/analysis-coverage.yml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ jobs:
106106
uses: actions/checkout@v4
107107
with:
108108
path: apps/app_api
109-
repository: cloud-py-api/app_api
109+
repository: nextcloud/app_api
110+
ref: stable29
110111

111112
- name: Install AppAPI
112113
run: |
@@ -248,7 +249,8 @@ jobs:
248249
uses: actions/checkout@v4
249250
with:
250251
path: apps/app_api
251-
repository: cloud-py-api/app_api
252+
repository: nextcloud/app_api
253+
ref: stable29
252254

253255
- name: Install AppAPI
254256
run: |
@@ -390,7 +392,8 @@ jobs:
390392
uses: actions/checkout@v4
391393
with:
392394
path: apps/app_api
393-
repository: cloud-py-api/app_api
395+
repository: nextcloud/app_api
396+
ref: stable29
394397

395398
- name: Install AppAPI
396399
run: |
@@ -525,10 +528,19 @@ jobs:
525528
run: python3 -m pip -v install ".[dev]"
526529

527530
- name: Checkout AppAPI
531+
if: ${{ matrix.nextcloud != 'master' }}
528532
uses: actions/checkout@v4
529533
with:
530534
path: apps/app_api
531-
repository: cloud-py-api/app_api
535+
repository: nextcloud/app_api
536+
ref: stable29
537+
538+
- name: Checkout AppAPI
539+
if: ${{ matrix.nextcloud == 'master' }}
540+
uses: actions/checkout@v4
541+
with:
542+
path: apps/app_api
543+
repository: nextcloud/app_api
532544

533545
- name: Install AppAPI
534546
run: |
@@ -692,10 +704,19 @@ jobs:
692704
run: python3 -m pip -v install ".[dev]"
693705

694706
- name: Checkout AppAPI
707+
if: ${{ matrix.nextcloud != 'master' }}
708+
uses: actions/checkout@v4
709+
with:
710+
path: apps/app_api
711+
repository: nextcloud/app_api
712+
ref: stable29
713+
714+
- name: Checkout AppAPI
715+
if: ${{ matrix.nextcloud == 'master' }}
695716
uses: actions/checkout@v4
696717
with:
697718
path: apps/app_api
698-
repository: cloud-py-api/app_api
719+
repository: nextcloud/app_api
699720

700721
- name: Install AppAPI
701722
run: |

nc_py_api/_session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def _response_event(self, response: Response) -> None:
301301

302302
def download2fp(self, url_path: str, fp, dav: bool, params=None, **kwargs):
303303
adapter = self.adapter_dav if dav else self.adapter
304-
with adapter.stream("GET", url_path, params=params) as response:
304+
with adapter.stream("GET", url_path, params=params, headers=kwargs.get("headers", None)) as response:
305305
check_error(response)
306306
for data_chunk in response.iter_raw(chunk_size=kwargs.get("chunk_size", 5 * 1024 * 1024)):
307307
fp.write(data_chunk)
@@ -425,7 +425,7 @@ async def _response_event(self, response: Response) -> None:
425425

426426
async def download2fp(self, url_path: str, fp, dav: bool, params=None, **kwargs):
427427
adapter = self.adapter_dav if dav else self.adapter
428-
async with adapter.stream("GET", url_path, params=params) as response:
428+
async with adapter.stream("GET", url_path, params=params, headers=kwargs.get("headers", None)) as response:
429429
check_error(response)
430430
async for data_chunk in response.aiter_raw(chunk_size=kwargs.get("chunk_size", 5 * 1024 * 1024)):
431431
fp.write(data_chunk)

nc_py_api/files/files.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,14 @@ def download_directory_as_zip(self, path: str | FsNode, local_path: str | Path |
115115
path = path.user_path if isinstance(path, FsNode) else path
116116
result_path = local_path if local_path else os.path.basename(path)
117117
with open(result_path, "wb") as fp:
118-
self._session.download2fp(
119-
"/index.php/apps/files/ajax/download.php", fp, dav=False, params={"dir": path}, **kwargs
120-
)
118+
if self._session.nc_version["major"] >= 31:
119+
full_path = dav_get_obj_path(self._session.user, path)
120+
accept_header = f"application/{kwargs.get('format', 'zip')}"
121+
self._session.download2fp(quote(full_path), fp, dav=True, headers={"Accept": accept_header})
122+
else:
123+
self._session.download2fp(
124+
"/index.php/apps/files/ajax/download.php", fp, dav=False, params={"dir": path}, **kwargs
125+
)
121126
return Path(result_path)
122127

123128
def upload(self, path: str | FsNode, content: bytes | str) -> FsNode:

nc_py_api/files/files_async.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,14 @@ async def download_directory_as_zip(
119119
path = path.user_path if isinstance(path, FsNode) else path
120120
result_path = local_path if local_path else os.path.basename(path)
121121
with open(result_path, "wb") as fp:
122-
await self._session.download2fp(
123-
"/index.php/apps/files/ajax/download.php", fp, dav=False, params={"dir": path}, **kwargs
124-
)
122+
if (await self._session.nc_version)["major"] >= 31:
123+
full_path = dav_get_obj_path(await self._session.user, path)
124+
accept_header = f"application/{kwargs.get('format', 'zip')}"
125+
await self._session.download2fp(quote(full_path), fp, dav=True, headers={"Accept": accept_header})
126+
else:
127+
await self._session.download2fp(
128+
"/index.php/apps/files/ajax/download.php", fp, dav=False, params={"dir": path}, **kwargs
129+
)
125130
return Path(result_path)
126131

127132
async def upload(self, path: str | FsNode, content: bytes | str) -> FsNode:

0 commit comments

Comments
 (0)