discstation 0.1.7 → 0.1.8

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "discstation",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "DiscStation optical-media appliance host — one cross-OS installer",
5
5
  "bin": {
6
6
  "discstation-setup": "scripts/setup.mjs"
@@ -1046,6 +1046,9 @@ def is_rewritable_disc(device):
1046
1046
  "",
1047
1047
  )
1048
1048
  return "rw" in media_line
1049
+ # Non-Linux: the RW signal comes from the ID_CDROM_MEDIA_*_RW keys above,
1050
+ # which discstation_host.media_properties() tags from the drutil/diskutil
1051
+ # media type.
1049
1052
  return False
1050
1053
 
1051
1054
 
@@ -1248,6 +1251,12 @@ def _classify_disc(device, props, failed, deadline):
1248
1251
  print(f"Disc inspection failed: {e}")
1249
1252
  kind = kind or "data_disc"
1250
1253
  return _disc_info(True, kind, web_type=_web_type_for(kind, 0))
1254
+ if props.get("ID_CDROM_MEDIA_STATE") == "blank":
1255
+ try:
1256
+ cap = discstation_burn.disc_capacity_bytes(device) or 0
1257
+ except Exception:
1258
+ cap = 0
1259
+ return _disc_info(True, "blank", capacity_bytes=cap, web_type="BLANK")
1251
1260
  return _disc_info(True, "unknown", web_type="UNKNOWN", failed_probes=failed)
1252
1261
 
1253
1262
  # Fast path for a blank disc: cdrom_id reports this reliably in ~20ms, and
@@ -163,6 +163,19 @@ def drive_status():
163
163
  return "unknown"
164
164
 
165
165
 
166
+ def _tag_rewritable(props, media_type):
167
+ """Set the ID_CDROM_MEDIA_*_RW key that discstation.is_rewritable_disc reads,
168
+ from a lowercased media-type string (drutil 'Type:' or diskutil 'Optical
169
+ Media Type'). ponytail: substring match — same heuristic as the rest of this
170
+ module."""
171
+ if "cd-rw" in media_type or "cdrw" in media_type:
172
+ props["ID_CDROM_MEDIA_CD_RW"] = "1"
173
+ elif "dvd-rw" in media_type or "dvd-ram" in media_type:
174
+ props["ID_CDROM_MEDIA_DVD_RW"] = "1"
175
+ elif "dvd+rw" in media_type or "bd-re" in media_type:
176
+ props["ID_CDROM_MEDIA_DVD_PLUS_RW"] = "1"
177
+
178
+
166
179
  def _drutil_media_properties():
167
180
  result = subprocess.run(["/usr/bin/drutil", "status"], capture_output=True, text=True, check=False, timeout=3)
168
181
  text = result.stdout + result.stderr
@@ -170,12 +183,16 @@ def _drutil_media_properties():
170
183
  if result.returncode != 0 or "no media" in lowered:
171
184
  return {}
172
185
  props = {"ID_CDROM": "1", "ID_CDROM_MEDIA": "1"}
173
- if "space used:" in lowered and "00:00:00" in lowered.split("space used:", 1)[1][:24]:
186
+ blank = "space used:" in lowered and "00:00:00" in lowered.split("space used:", 1)[1][:24]
187
+ if blank:
174
188
  props["ID_CDROM_MEDIA_STATE"] = "blank"
175
- if "type: cd" in lowered:
176
- props["ID_CDROM_MEDIA_TYPE"] = "audio"
177
- elif "type: dvd" in lowered:
189
+ match = re.search(r"type:\s*([a-z0-9+\-]+)", lowered)
190
+ media_type = match.group(1) if match else ""
191
+ if media_type.startswith("dvd") or media_type.startswith("bd"):
178
192
  props["ID_CDROM_MEDIA_TYPE"] = "dvd"
193
+ elif media_type.startswith("cd") and not blank and "-r" not in media_type:
194
+ props["ID_CDROM_MEDIA_TYPE"] = "audio"
195
+ _tag_rewritable(props, media_type)
179
196
  return props
180
197
 
181
198
 
@@ -187,7 +204,7 @@ def media_properties(device):
187
204
  except subprocess.TimeoutExpired:
188
205
  return _drutil_media_properties()
189
206
  if disk.returncode != 0:
190
- return {}
207
+ return _drutil_media_properties()
191
208
  fields = {}
192
209
  for line in disk.stdout.splitlines():
193
210
  if ":" in line:
@@ -195,7 +212,7 @@ def media_properties(device):
195
212
  fields[key.strip()] = value.strip()
196
213
  optical = fields.get("Optical Media Type", "")
197
214
  if not optical and not fields.get("Device / Media Name"):
198
- return {}
215
+ return _drutil_media_properties()
199
216
  props = {"ID_CDROM": "1", "ID_CDROM_MEDIA": "1"}
200
217
  label = fields.get("Volume Name", "")
201
218
  filesystem = fields.get("Type (Bundle)") or fields.get("File System Personality")
@@ -223,8 +240,9 @@ def media_properties(device):
223
240
  optical = optical.lower()
224
241
  if "dvd+r dl" in optical or "dvd-r dl" in optical:
225
242
  props["ID_CDROM_MEDIA_DVD_PLUS_R_DL"] = "1"
226
- elif "dvd+r" in optical or "dvd-r" in optical:
243
+ elif ("dvd+r" in optical or "dvd-r" in optical) and "rw" not in optical:
227
244
  props["ID_CDROM_MEDIA_DVD_PLUS_R"] = "1"
245
+ _tag_rewritable(props, optical)
228
246
  return props
229
247
  return {}
230
248