Browse Source

don't delete a folder that doesn't exist

current_wdka_release
crunk 3 years ago
parent
commit
76de0b10cb
  1. 6
      verse/adminpage.py
  2. 9
      verse/distribusiselector.py
  3. 3
      verse/upload.py

6
verse/adminpage.py

@ -107,9 +107,11 @@ def DeleteDistribusiFromDb(distribusi):
def DeleteDistribusiFiles(distribusiname):
userfolder = os.path.join("stash", distribusiname)
shutil.rmtree(userfolder)
if os.path.exists(userfolder):
shutil.rmtree(userfolder)
cssfolder = os.path.join("themes/userthemes", distribusiname)
shutil.rmtree(cssfolder)
if os.path.exists(cssfolder):
shutil.rmtree(cssfolder)
def AddDistribusisToForm(admindistribusiform):

9
verse/distribusiselector.py

@ -83,16 +83,19 @@ def DeleteDistribusi(distribusiname):
db.session.delete(distribusi)
db.session.commit()
userfolder = os.path.join("stash", distribusi.distribusiname)
shutil.rmtree(userfolder)
if os.path.exists(userfolder):
shutil.rmtree(userfolder)
cssfolder = os.path.join(
"themes/userthemes", distribusi.distribusiname
)
shutil.rmtree(cssfolder)
if os.path.exists(cssfolder):
shutil.rmtree(cssfolder)
if distribusi.publictheme is not None:
publicthemefolder = os.path.join(
"themes/publicthemes", distribusi.distribusiname
)
shutil.rmtree(publicthemefolder)
if os.path.exists(publicthemefolder):
shutil.rmtree(publicthemefolder)
# SelectField error is list is a tuple?? why??
# selectorform.distribusis.errors.append("Distribusi deleted!")
except (InvalidRequestError, DataError, InterfaceError, DatabaseError):

3
verse/upload.py

@ -86,7 +86,8 @@ def UploadUpdatedFiles(uploadfolder):
zipfile.save(os.path.join(uploadfolder, zipfilename))
newuserfolder = os.path.join("stash", distribusi.distribusiname)
shutil.rmtree(newuserfolder)
if os.path.exists(newuserfolder):
shutil.rmtree(newuserfolder)
os.mkdir(newuserfolder)
copyzipfile = os.path.join(uploadfolder, zipfilename)

Loading…
Cancel
Save