Package com.frostwire.jlibtorrent
Enum Class MoveFlags
- All Implemented Interfaces:
Serializable,Comparable<MoveFlags>,Constable
Flags controlling storage move behavior for torrent files.
MoveFlags specifies how the BitTorrent session should handle file conflicts
when moving a torrent's downloaded data to a new location on disk. This is useful
for disk space management, organizing downloads, or migrating between storage devices.
Understanding Storage Move Operations:
Moving torrent storage involves copying or moving files from current location to a
new directory. These flags control what happens if files already exist at the destination:
- ALWAYS_REPLACE_FILES: Overwrite any existing destination files
- FAIL_IF_EXIST: Abort operation if destination files exist (safest)
- DONT_REPLACE: Use existing destination files instead of copying
Moving Torrent Storage:
// Get handle to active torrent
TorrentHandle th = sm.find(infoHash);
// Move downloads to new location
String newPath = \"/mnt/faster_disk/downloads\";
th.moveStorage(newPath, MoveFlags.ALWAYS_REPLACE_FILES);
// Operation is asynchronous; listen for completion
sm.addListener(new AlertListener() {
public int[] types() {
return new int[] {AlertType.STORAGE_MOVED.swig()};
}
public void alert(Alert<?> alert) {
StorageMovedAlert sma = (StorageMovedAlert) alert;
System.out.println(\"Storage moved to: \" + sma.path());
}
});
MoveFlags Comparison:
| Flag | Behavior | Use Case | Safety |
|---|---|---|---|
| ALWAYS_REPLACE_FILES | Overwrites existing destination files | Cleanup/reorganization, trusted destinations | Medium - deletes existing data |
| FAIL_IF_EXIST | Aborts if destination files exist | Automated operations, safety-critical | High - preserves existing files |
| DONT_REPLACE | Uses existing destination files | Resume after crash, keep newer versions | Medium - assumes destination is correct |
Real-World Scenarios:
// Scenario 1: Disk full - move to larger drive // Use ALWAYS_REPLACE_FILES (trusted new location) String newDisk = \"/media/external/torrents\"; th.moveStorage(newDisk, MoveFlags.ALWAYS_REPLACE_FILES); // Scenario 2: Automated organization system // Use FAIL_IF_EXIST (safety check, abort on conflicts) String organized = \"/data/organized/\" + category; th.moveStorage(organized, MoveFlags.FAIL_IF_EXIST); // Scenario 3: Restart after crash // Use DONT_REPLACE (keep partially downloaded files) String resumed = \"/downloads/resumed\"; th.moveStorage(resumed, MoveFlags.DONT_REPLACE);
Move Completion Detection:
// Listen for move operations
sm.addListener(new AlertListener() {
public int[] types() {
return new int[] {
AlertType.STORAGE_MOVED.swig(),
AlertType.STORAGE_MOVED_FAILED.swig()
};
}
public void alert(Alert<?> alert) {
if (alert.type() == AlertType.STORAGE_MOVED) {
StorageMovedAlert sma = (StorageMovedAlert) alert;
System.out.println(\"✓ Moved to: \" + sma.path());
} else {
StorageMovedFailedAlert smfa = (StorageMovedFailedAlert) alert;
System.out.println(\"✗ Move failed: \" + smfa.message());
}
}
});
Important Notes:
- Move operation is asynchronous; check STORAGE_MOVED alert for completion
- Destination directory should exist before move
- Current downloads continue during move operation
- Operation may fail if insufficient disk space
- Use FAIL_IF_EXIST for programmatic safety
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionReplace any files in the destination when copying or moving the storage.If any files exist in the target, take those files instead of the ones we may have in the source.If any files that we want to copy exist in the destination, fail the whole operation and don't perform any copy or move. -
Method Summary
Modifier and TypeMethodDescriptionstatic MoveFlagsfromSwig(com.frostwire.jlibtorrent.swig.move_flags_t swigValue) com.frostwire.jlibtorrent.swig.move_flags_tswig()static MoveFlagsReturns the enum constant of this class with the specified name.static MoveFlags[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
ALWAYS_REPLACE_FILES
Replace any files in the destination when copying or moving the storage. -
FAIL_IF_EXIST
If any files that we want to copy exist in the destination, fail the whole operation and don't perform any copy or move. There is an inherent race condition in this mode. The files are checked for existence before the operation starts. In between the check and performing the copy, the destination files may be created, in which case they are replaced. -
DONT_REPLACE
If any files exist in the target, take those files instead of the ones we may have in the source.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
swig
public com.frostwire.jlibtorrent.swig.move_flags_t swig()- Returns:
- the native value
-
fromSwig
- Parameters:
swigValue- the native value
-