MoveFileWrapper.sh

From LinuxMCE
Jump to: navigation, search

moveFileWrapper.sh is the script on the system which will do the appropriate moving of files. It should provide two use cases, one for if the file is on the same disk, in which case mv is used, and it would be so fast, that no progress information would need to be output. The second use case would be to simulate a copy and delete while extracting progress information to be output back using MessageSend.

Grab inspiration from

  • src/Disk_Drive/ripDiskWrapper.sh
  • src/Disk_Drive/Pluto_Progress.sh
  • src/Disk_Drive/DiskCopy_ProgressExtract.sh

NOTE: Grab isReadOnly, isFullDisk from the ripDiskWrapper.sh for use in the new script!

Parameters

  • $1 Media PlugIn Device ID
  • $2 job ID
  • $3 task ID
  • $4 source Filename (this may contain spaces, deal with it.)
  • $5 destination filename (this may contain spaces, deal with it)

Use Cases

The two basic use cases outlined above should be sufficient for this first pass.

Move file on same Disk

Use unix mv. Use MessageSend to report success or failure. See #Reporting Values

Move file to different Disk

Find a method that can report progress. Use whatever means necessary to extract progress information (at least percentage, time remaining and a human readable byte count would be nice too), and to send a progress message via MessageSend, as well as report success or failure.

Reporting Values

As in Pluto_Progress.sh, use MessageSend to report back values, in the format:

/usr/pluto/bin/MessageSend $DCERouter 0 $1 1 1089 9 "Some text to return" 102 "# of seconds remaining" 199 "p s or e" 256 "percentage" 257 "$3" 258 "$2"

A Short Explanation of the MessageSend Values

  • $DCERouter is defined in Config_Ops.sh for you.
  • 0 (from MessageSend)
  • $1 (from the media plugin device ID)
  • 1 MESSAGETYPE_COMMAND
  • 1089 is the CMD_Update_Move_Progress command
  • 9 is the CommandParameter type for Text.
  • "Some Text To Return" .. you can put whatever you want here, and it will be passed back to the task to be displayed in its status slot.
  • 102 is the CommandParameter type for Time
  • # of seconds remaining is just what it sounds like, do any conversions needed to convert your progress measurement to seconds.
  • 199 is the CommandParameter type for Status
  • the Status value can be either:
    • p for Progress. This means that the task is still going, and you're just reporting a percentage.
    • s for Success. This command completed successfully, time should be 0, and percent should be 100.
    • e for Error. This command failed. Time should be 0, percent should be where it stopped, and Text should contain the nature of the error to report back to the Orbiter.
  • 256 is the CommandParameter type for Percentage
  • replace "Percentage" with "0" to "100" in percentage.
  • 257 is the CommandParameter type for Task ID
  • $3 should be passed in as the Task ID
  • 258 is the CommandParameter type for Job ID
  • $2 should be passed in as the Job ID

Hope this is enough. --Tschak909 00:19, 30 April 2011 (CEST)