Skip to content

Commit

Permalink
Fix versions to match updated envd version
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubno committed Jan 13, 2025
1 parent 9e21ff4 commit f4369e1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/js-sdk/src/envd/versions.ts
Original file line number Diff line number Diff line change
@@ -0,0 1 @@
export const ENVD_VERSION_RECURSIVE_WATCH = '0.1.4'
3 changes: 2 additions & 1 deletion packages/js-sdk/src/sandbox/filesystem/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 24,7 @@ import { WatchHandle, FilesystemEvent } from './watchHandle'

import { compareVersions } from 'compare-versions'
import { TemplateError } from '../../errors'
import {ENVD_VERSION_RECURSIVE_WATCH} from '../../envd/versions'

/**
* Sandbox filesystem object information.
Expand Down Expand Up @@ -442,7 443,7 @@ export class Filesystem {
onEvent: (event: FilesystemEvent) => void | Promise<void>,
opts?: WatchOpts
): Promise<WatchHandle> {
if (opts?.recursive && this.envdApi.version && compareVersions(this.envdApi.version, '0.1.3') < 0) {
if (opts?.recursive && this.envdApi.version && compareVersions(this.envdApi.version, ENVD_VERSION_RECURSIVE_WATCH) < 0) {
throw new TemplateError(
'You need to update the template to use recursive watching. '
'You can do this by running `e2b template build` in the directory with the template.'
Expand Down
3 changes: 3 additions & 0 deletions packages/python-sdk/e2b/envd/versions.py
Original file line number Diff line number Diff line change
@@ -0,0 1,3 @@
from packaging.version import Version

ENVD_VERSION_RECURSIVE_WATCH = Version("0.1.4")
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 14,7 @@
from e2b.envd.api import ENVD_API_FILES_ROUTE, ahandle_envd_api_exception
from e2b.envd.filesystem import filesystem_connect, filesystem_pb2
from e2b.envd.rpc import authentication_header, handle_rpc_exception
from e2b.envd.versions import ENVD_VERSION_RECURSIVE_WATCH
from e2b.exceptions import SandboxException, TemplateException
from e2b.sandbox.filesystem.filesystem import EntryInfo, map_file_type
from e2b.sandbox.filesystem.watch_handle import FilesystemEvent
Expand Down Expand Up @@ -361,7 362,11 @@ async def watch_dir(
:return: `AsyncWatchHandle` object for stopping watching directory
"""
if recursive and self._envd_version is not None and Version(self._envd_version) < Version("0.1.3"):
if (
recursive
and self._envd_version is not None
and Version(self._envd_version) < ENVD_VERSION_RECURSIVE_WATCH
):
raise TemplateException(
"You need to update the template to use recursive watching. "
"You can do this by running `e2b template build` in the directory with the template."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 6,7 @@
import httpx
from packaging.version import Version

from e2b.envd.versions import ENVD_VERSION_RECURSIVE_WATCH
from e2b.exceptions import TemplateException
from e2b.connection_config import (
ConnectionConfig,
Expand Down Expand Up @@ -353,7 354,11 @@ def watch_dir(
:return: `WatchHandle` object for stopping watching directory
"""
if recursive and self._envd_version is not None and Version(self._envd_version) < Version("0.1.3"):
if (
recursive
and self._envd_version is not None
and Version(self._envd_version) < ENVD_VERSION_RECURSIVE_WATCH
):
raise TemplateException(
"You need to update the template to use recursive watching. "
"You can do this by running `e2b template build` in the directory with the template."
Expand Down

0 comments on commit f4369e1

Please sign in to comment.