Don't treat filename collisions as fatal.
This commit is contained in:
parent
e96d373eec
commit
0e9953882c
|
@ -1270,10 +1270,8 @@ Use 'ls -l' to see URLs."""
|
|||
# Derive a filename if one hasn't been set
|
||||
if not filename:
|
||||
filename = gi.derive_filename(self.mime if saving_current else None)
|
||||
|
||||
# Check for filename collisions
|
||||
if os.path.exists(filename):
|
||||
print("File %s already exists!" % filename)
|
||||
filename = util.handle_filename_collisions(filename)
|
||||
if not filename:
|
||||
return
|
||||
|
||||
# Actually do the save operation
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
import os.path
|
||||
|
||||
# Cheap and cheerful URL detector
|
||||
def looks_like_url(word):
|
||||
return "." in word and word.startswith("gemini://")
|
||||
|
||||
def handle_filename_collisions(filename):
|
||||
while os.path.exists(filename):
|
||||
print("File %s already exists!" % filename)
|
||||
filename = input("Choose a new one, or leave blank to abort: ")
|
||||
return filename
|
||||
|
||||
def ask_yes_no(prompt, default=None):
|
||||
print(prompt)
|
||||
if default == True:
|
||||
|
|
Loading…
Reference in New Issue