react-native-kookit 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -42,9 +42,8 @@ class JcifsShareEnumerator {
|
|
|
42
42
|
} ?: emptyList()
|
|
43
43
|
|
|
44
44
|
} catch (e: Exception) {
|
|
45
|
-
// If JCIFS enumeration fails,
|
|
46
|
-
|
|
47
|
-
emptyList()
|
|
45
|
+
// If JCIFS enumeration fails, throw exception
|
|
46
|
+
throw Exception("Failed to enumerate shares using JCIFS: " + e.message)
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
|
|
@@ -83,54 +83,33 @@ class SmbClient {
|
|
|
83
83
|
fun listShares(): List<String> {
|
|
84
84
|
val s = session ?: throw IOException("Not authenticated")
|
|
85
85
|
|
|
86
|
-
//
|
|
87
|
-
if (lastHost
|
|
88
|
-
|
|
89
|
-
val shares = jcifsEnumerator.listShares(
|
|
90
|
-
lastHost!!,
|
|
91
|
-
lastUsername!!,
|
|
92
|
-
lastPassword!!,
|
|
93
|
-
lastDomain ?: ""
|
|
94
|
-
)
|
|
95
|
-
if (shares.isNotEmpty()) {
|
|
96
|
-
return shares
|
|
97
|
-
}
|
|
98
|
-
} catch (e: Exception) {
|
|
99
|
-
// JCIFS failed, fall back to SMBJ testing approach
|
|
100
|
-
}
|
|
86
|
+
// Check if we have the necessary credentials
|
|
87
|
+
if (lastHost == null || lastUsername == null || lastPassword == null) {
|
|
88
|
+
throw IOException("Missing host or credentials for share enumeration")
|
|
101
89
|
}
|
|
102
90
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
val
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
val allTestShares = windowsShares + commonShares
|
|
91
|
+
// Use JCIFS for share enumeration, no fallback to other methods
|
|
92
|
+
try {
|
|
93
|
+
val shares = jcifsEnumerator.listShares(
|
|
94
|
+
lastHost!!,
|
|
95
|
+
lastUsername!!,
|
|
96
|
+
lastPassword!!,
|
|
97
|
+
lastDomain ?: ""
|
|
98
|
+
)
|
|
113
99
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
val testShare = s.connectShare(shareName)
|
|
118
|
-
testShare.close()
|
|
119
|
-
availableShares.add(shareName)
|
|
120
|
-
} catch (e: Exception) {
|
|
121
|
-
// Share doesn't exist, access denied, or other error - ignore
|
|
122
|
-
}
|
|
100
|
+
// If shares list is empty, throw an error
|
|
101
|
+
if (shares.isEmpty()) {
|
|
102
|
+
throw IOException("No shares found on server")
|
|
123
103
|
}
|
|
124
104
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
105
|
+
return shares
|
|
106
|
+
} catch (e: Exception) {
|
|
107
|
+
// Directly propagate the error without fallback
|
|
108
|
+
if (e is IOException) {
|
|
109
|
+
throw e
|
|
128
110
|
} else {
|
|
129
|
-
|
|
111
|
+
throw IOException("Failed to enumerate shares: " + e.message, e)
|
|
130
112
|
}
|
|
131
|
-
} catch (e: Exception) {
|
|
132
|
-
// Final fallback to common share names if all enumeration methods fail
|
|
133
|
-
listOf("C$", "shared", "public", "data")
|
|
134
113
|
}
|
|
135
114
|
}
|
|
136
115
|
|
package/package.json
CHANGED