diff --git a/platforms/android/app/src/main/java/com/foxdebug/acode/sftp/Sftp.java b/platforms/android/app/src/main/java/com/foxdebug/acode/sftp/Sftp.java index f1822e13c..f38a0af44 100644 --- a/platforms/android/app/src/main/java/com/foxdebug/acode/sftp/Sftp.java +++ b/platforms/android/app/src/main/java/com/foxdebug/acode/sftp/Sftp.java @@ -1135,7 +1135,7 @@ public void run() { return; } callback.error("Not connected"); - } catch (IOException | JSONException e) { + } catch (IOException | JSONException | RuntimeException e) { callback.error(errMessage(e)); } } @@ -1186,7 +1186,7 @@ public void run() { } catch ( IOException | URISyntaxException - | SecurityException + | RuntimeException | SshException e ) { Log.e("getFile", "Error downloading file", e); @@ -1386,8 +1386,8 @@ public void run() { "lastModified", fileAttributes.lastModifiedTime() ); - String[] pathSegments = uri.getPath().split("/"); - String filename = pathSegments[pathSegments.length - 1]; + String filename = new File(uri.getPath()).getName(); + if (filename.isEmpty()) filename = "/"; fileStat.put("name", filename); fileStat.put("url", uri.getPath()); @@ -1428,7 +1428,7 @@ public void run() { return; } callback.error("Not connected"); - } catch (URISyntaxException | JSONException | SshException e) { + } catch (URISyntaxException | JSONException | SshException | RuntimeException e) { callback.error(errMessage(e)); } } @@ -1450,7 +1450,7 @@ public void run() { return; } callback.error("Not connected"); - } catch (SftpStatusException | SshException e) { + } catch (SftpStatusException | SshException | RuntimeException e) { callback.error(errMessage(e)); } } @@ -1475,7 +1475,7 @@ public void run() { return; } callback.error("Not connected"); - } catch (SftpStatusException | SshException e) { + } catch (SftpStatusException | SshException | RuntimeException e) { callback.error(errMessage(e)); } } @@ -1518,7 +1518,7 @@ public void run() { } callback.error("Not connected"); } catch ( - SftpStatusException | SshException | TransferCancelledException e + SftpStatusException | SshException | TransferCancelledException | RuntimeException e ) { callback.error(errMessage(e)); } @@ -1543,7 +1543,7 @@ public void run() { return; } callback.error("Not connected"); - } catch (SftpStatusException | SshException e) { + } catch (SftpStatusException | SshException | RuntimeException e) { callback.error(errMessage(e)); } } @@ -1564,7 +1564,7 @@ public void run() { return; } callback.error("Not connected"); - } catch (SftpStatusException | SshException e) { + } catch (SftpStatusException | SshException | RuntimeException e) { callback.error(errMessage(e)); } }