the further adventures of

Mike Pirnat

a leaf on the wind

AppleTV and the Mysterious iTunesDB.tmp Files

So after I upgraded to iTunes 10 and did the necessary bits of extra hackery to make the UI reasonable again, iTunes decided to lose track of my AppleTV (probably as a result of my fiddling with plists to try to fix this annoying regression), which forced me to do a full re-sync of my entire library.

Three days later (I pushed around 165GB over my wireless network), the sync was complete, but I noticed a giant 282GB blob of "Other" stuff on the disk allocation graph in iTunes. When I logged into the AppleTV to see what was going on, I discovered that during the sync process, something was causing my AppleTV to drop 78MB iTunesDB.tmp files in my /mnt/Media directory.

A lot of them.

Just north of 3600, in fact.

So... yeah, there's my 280+ GB of "Other". Ouch! So much for that nice new 500GB external drive! My initial testing didn't seem to indicate that their presence or absence mattered at all for normal use, so I nuked them and freed up a ton of disk space. I have observed that I get one to three more of them every time iTunes syncs to the AppleTV, though, so eventually they'll be a problem again.

Does anyone know what these files are or why they're written to disk during syncs? Or more importantly, do you know what should be--but clearly isn't--cleaning them up?

Read and Post Comments

The Zen of Doing It Wrong

A coworker unearthed this little treasure today... I think it's a vestigial structure to assist Diaper (anti)Pattern treatment during testing or debugging, but it's still gross to see it in real, live production code. (Oddly enough, I couldn't find a good "Diaper Pattern" link whilst Googling about--surely I'm not the only one who uses this term?) Anyway, without further ado:

try:
    os.remove(filename)
except:
    raise
    pass
try:
    os.remove(os.path.join(TMP,'out-%s' % base_filename))
except:
    raise
    pass
try:
    os.remove(os.path.join(TMP,'properties_%s.lock' % brandid_human))
except:
    raise
    pass

If an exception is raised, raise an exception... It has a certain zenlike beauty to its awfulness. The use of the Diaper Pattern is bad enough, but this guarantees blowouts!

Read and Post Comments

Python: You're Doing It Wrong

A coworker just showed me this little gem--a maintenance script that's got no author attribution and isn't in source control, so whoever has perpetrated this crime against all that's good and holy remains anonymous and (for the moment) safe from our wrath. I'm so completely taken aback by this--I... I don't know what to say. I just have to share.

#!/usr/bin/env python
import os,sys
C=os.chdir
S=os.system
M=os.mkdir
J=os.path.join
A=os.path.abspath
D=os.path.dirname
E=os.path.exists
W=sys.stdout.write
V=sys.argv
X=sys.exit
ERR=lambda m:W(m+"\n")
PRNT=lambda m:W(m+"\n")
assert len(V)==2,"you must provide a sandbox name"
SB=V[1]
H=A(D(__file__))
SBD=J(D(H),SB)
C(SBD)
PST=J(SBD,'bin/paster')
VAR=J(SBD,'var')
ETC=J(SBD,'etc')
S("mkdir -p "+VAR)
PRNT("restarting "+SB)
CMD=";".join(['source %s'%J(SBD,'bin/activate'),PST+" serve --daemon --pid-file=%s/sandbox.pid --log-file=%s/sandbox.log %s/sandbox.ini start"%(VAR,VAR,ETC)])
PRNT(CMD)
S(CMD)
PRNT("All done!")
X(0)

Weep for us.

Read and Post Comments