Skip to content

Commit

Permalink
Before having jcifs-ng make a discovery request, check if we resolved…
Browse files Browse the repository at this point in the history
… that in our cache

This seem to fix discovery failures for me,
against a Freebox Server that exclusively exposes mDNS
  • Loading branch information
phhusson committed Dec 8, 2024
1 parent ca43dfa commit e0218bc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/com/archos/filecorelibrary/smbj/SmbjUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import com.archos.filecorelibrary.jcifs.JcifsUtils;
import com.archos.filecorelibrary.samba.NetworkCredentialsDatabase;
import com.archos.filecorelibrary.samba.SambaDiscovery;

import com.hierynomus.msfscc.FileAttributes;
import com.hierynomus.msfscc.fileinformation.FileIdBothDirectoryInformation;
Expand Down Expand Up @@ -97,7 +98,9 @@ public synchronized void getSmbConnection(Uri uri) throws IOException, SMBApiExc
SMBClient smbClient;
if (smbConfig != null) smbClient = new SMBClient(smbConfig);
else smbClient = new SMBClient();
final String serverIP = JcifsUtils.getInstance(mContext).getBaseContextOnly(true).getNameServiceClient().getByName(server).getHostAddress();
String serverIP = SambaDiscovery.getIpFromShareName(server);
if (serverIP == null)
serverIP = JcifsUtils.getInstance(mContext).getBaseContextOnly(true).getNameServiceClient().getByName(server).getHostAddress();
log.trace("getSmbConnection: {} -> {}", server, serverIP);
if (port != -1) smbConnection = smbClient.connect(serverIP, port);
else smbConnection = smbClient.connect(serverIP);
Expand Down

0 comments on commit e0218bc

Please sign in to comment.