Skip to content

Commit

Permalink
main partial fix UniversalMediaServer#5095
Browse files Browse the repository at this point in the history
better handle linux video, audio and picture Dir as default share
  • Loading branch information
SurfaceS committed Nov 7, 2024
1 parent e7a0f94 commit 6ad9b3a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,11 @@
<artifactId>jsoup</artifactId>
<version>1.18.1</version>
</dependency>
<dependency>
<groupId>dev.dirs</groupId>
<artifactId>directories</artifactId>
<version>26</version>
</dependency>
</dependencies>
<build>
<defaultGoal>assembly:assembly</defaultGoal>
Expand Down
26 changes: 15 additions & 11 deletions src/main/java/net/pms/platform/PlatformUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.sun.jna.Platform;
import com.sun.jna.platform.FileUtils;
import com.vdurmont.semver4j.Semver;
import dev.dirs.UserDirectories;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -239,18 +240,21 @@ public List<Path> getDefaultFolders() {
if (defaultFolders == null) {
// Lazy initialization
List<Path> result = new ArrayList<>();
result.add(Paths.get("").toAbsolutePath());
String userHome = System.getProperty("user.home");
if (StringUtils.isNotBlank(userHome)) {
result.add(Paths.get(userHome));
UserDirectories userDirs = UserDirectories.get();
if (userDirs.videoDir != null) {
result.add(Paths.get(userDirs.videoDir));
if (userDirs.audioDir != null) {
result.add(Paths.get(userDirs.audioDir));
}
if (userDirs.pictureDir != null) {
result.add(Paths.get(userDirs.pictureDir));
}
if (userDirs.publicDir != null) {
result.add(Paths.get(userDirs.publicDir));
}
} else {
result.add(Paths.get(userDirs.homeDir));
}
//TODO: (Nad) Implement xdg-user-dir for Linux when EnginesRegistration is merged:
// xdg-user-dir DESKTOP
// xdg-user-dir DOWNLOAD
// xdg-user-dir PUBLICSHARE
// xdg-user-dir MUSIC
// xdg-user-dir PICTURES
// xdg-user-dir VIDEOS
defaultFolders = Collections.unmodifiableList(result);
}
return defaultFolders;
Expand Down

0 comments on commit 6ad9b3a

Please sign in to comment.