Strange problem when saving file 13.5.2 (Solved. Not a bug)

Discuss Moho bugs (or suspected bugs) with other users. To report bugs to Smith Micro, please visit support.smithmicro.com

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
davoodice2
Posts: 381
Joined: Tue Jun 15, 2021 1:14 pm

Strange problem when saving file 13.5.2 (Solved. Not a bug)

Post by davoodice2 »

hi.
some times when I save File it doesn't save !!!
actually it saves but not in my file . it saves with a strange name in other file !
please see the video.

save with these names
Image

SOLVED!
I forgot to close first file :D . But why did it work before?! :? :shock:
Last edited by davoodice2 on Thu Nov 11, 2021 9:00 am, edited 2 times in total.
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
davoodice2
Posts: 381
Joined: Tue Jun 15, 2021 1:14 pm

Re: Strange bug when saving file 13.5.2

Post by davoodice2 »

now I known this is not a bug.
it happens after run this script.

Code: Select all

function DV_Incremental_Save:Run(moho)    
local path = moho.document:Path()
if (path == "") then     
    local alert =  LM.GUI.Alert(LM.GUI.ALERT_WARNING,
                MOHO.Localize("/Scripts/tool/SaveIncrement/FirstSave=Please save your file"),
                nil,
                nil,
                MOHO.Localize("/Scripts/OK=OK"),
                MOHO.Localize("/Scripts/CANCEL=CANCEL"),
                nil)
            if alert == 1 then       
                do return end 
            end    
    moho.FileSave()  
else
   local OS1 = package.config:sub(1,1)
    if OS1 ~= "/" then
     OS1 = "\\"
     end  
   local name = moho.document:Name()
   local file = io.open(path, "rb")
   local source_content = file:read("*all")
   local version_number = 1 
   local file_name_part = string.gsub(name,".moho", "")
   local dir_part = string.gsub(path,name, "")

   local backup_folder = dir_part..file_name_part.. [[ Incremental Saves]] ..OS1
  os.execute( "mkdir ".. '"' .. backup_folder .. '"' )
  
  local path = backup_folder
    moho:BeginFileListing(path)
	local fileName = moho:GetNextFile()
    while fileName ~= nil do
		sepPos = string.find(fileName, ".", 1, true)
		if (sepPos ~= nil) then
			local extn = string.sub(fileName, sepPos + 1)
			if (extn == "moho") then        
                local corr = string.find(fileName, "_%d+.moho")  
                if (corr ~= nil) then  
                        local current = tonumber(string.match(string.match(fileName, "_%d+.moho"), "%d+"))
                        if( current >= version_number) then
                            version_number = current+1
                        end
                end           
            end
        end  
        fileName = moho:GetNextFile()
    end   
local new = file_name_part .. '_'..version_number..'.moho'
file = io.open(path..new, "wb")
file:write(source_content)
file:close(path..name)
moho:FileSave()  
moho:Click()              
end
end
I think it happens because of file:Close() problem
any help please?
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
Víctor Paredes
Site Admin
Posts: 5671
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Re: Strange bug when saving file 13.5.2 (Solved. Not a bug)

Post by Víctor Paredes »

To make the saving process safer and avoid the 0k files' issue sometimes appeared, when you save, 13.5.2 saves a copy of the file first. Once that saving is complete, Moho replaces the old file with the new one.
This process is normally extremely quick, but it can vary depending on how heavy the file is.
We made this change to be sure that if anything goes wrong with the software or the computer while saving, users won't lose their files.
Image Image Image Image
Moho Product Manager

www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
User avatar
synthsin75
Posts: 9985
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Strange bug when saving file 13.5.2 (Solved. Not a bug)

Post by synthsin75 »

Why does file:close have an argument? You only need an argument when using the syntax io.close(path).

And why are you writing the content of the file, instead of just saving it to a new name?
User avatar
davoodice2
Posts: 381
Joined: Tue Jun 15, 2021 1:14 pm

Re: Strange bug when saving file 13.5.2 (Solved. Not a bug)

Post by davoodice2 »

Víctor Paredes wrote: Wed Nov 10, 2021 11:55 pm To make the saving process safer and avoid the 0k files' issue sometimes appeared, when you save, 13.5.2 saves a copy of the file first. Once that saving is complete, Moho replaces the old file with the new one.
This process is normally extremely quick, but it can vary depending on how heavy the file is.
We made this change to be sure that if anything goes wrong with the software or the computer while saving, users won't lose their files.
very intelligent improve I see that in maya too. even when rendering it create a copy of file and renders that for prevent changing scene during render.
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
davoodice2
Posts: 381
Joined: Tue Jun 15, 2021 1:14 pm

Re: Strange bug when saving file 13.5.2 (Solved. Not a bug)

Post by davoodice2 »

synthsin75 wrote: Thu Nov 11, 2021 1:44 am Why does file:close have an argument? You only need an argument when using the syntax io.close(path).
just my mistake .
synthsin75 wrote: Thu Nov 11, 2021 1:44 am And why are you writing the content of the file, instead of just saving it to a new name?
because I want to store a copy of file before current saving. its easy if just save with increment name in current folder. but when i want to save backups in another folder it's become tricky. i have to copy my file before saving changes and working file name must stay same as before.
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
davoodice2
Posts: 381
Joined: Tue Jun 15, 2021 1:14 pm

Re: Strange bug when saving file 13.5.2 (Solved. Not a bug)

Post by davoodice2 »

Víctor Paredes wrote: Wed Nov 10, 2021 11:55 pm To make the saving process safer and avoid the 0k files' issue sometimes appeared, when you save, 13.5.2 saves a copy of the file first. Once that saving is complete, Moho replaces the old file with the new one.
This process is normally extremely quick, but it can vary depending on how heavy the file is.
We made this change to be sure that if anything goes wrong with the software or the computer while saving, users won't lose their files.
hi victor.
Based on the problem that has arisen now, I have three suggestions:
First, the small icon next to the document name tab will not disappear until the file is saved successfully.
And secondly, if there is a problem for saving file for any reason, the moho give us a message.
And third, FileSave() function have a returned value for checking successful save.
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
synthsin75
Posts: 9985
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Strange bug when saving file 13.5.2 (Solved. Not a bug)

Post by synthsin75 »

davoodice2 wrote: Thu Nov 11, 2021 8:59 am
synthsin75 wrote: Thu Nov 11, 2021 1:44 am And why are you writing the content of the file, instead of just saving it to a new name?
because I want to store a copy of file before current saving. its easy if just save with increment name in current folder. but when i want to save backups in another folder it's become tricky. i have to copy my file before saving changes and working file name must stay same as before.
ScriptInterface:FileSaveAs(path) can save with the same file name to a different location, defined in the path.
And you can reopen the original file using ScriptInterface:FileOpen(path).
User avatar
davoodice2
Posts: 381
Joined: Tue Jun 15, 2021 1:14 pm

Re: Strange bug when saving file 13.5.2 (Solved. Not a bug)

Post by davoodice2 »

synthsin75 wrote: Thu Nov 11, 2021 5:42 pm
davoodice2 wrote: Thu Nov 11, 2021 8:59 am
synthsin75 wrote: Thu Nov 11, 2021 1:44 am And why are you writing the content of the file, instead of just saving it to a new name?
because I want to store a copy of file before current saving. its easy if just save with increment name in current folder. but when i want to save backups in another folder it's become tricky. i have to copy my file before saving changes and working file name must stay same as before.
ScriptInterface:FileSaveAs(path) can save with the same file name to a different location, defined in the path.
And you can reopen the original file using ScriptInterface:FileOpen(path).
please Notice: We must store file before any changes we made. FileSaveAs or save cant do these
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
synthsin75
Posts: 9985
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Strange bug when saving file 13.5.2 (Solved. Not a bug)

Post by synthsin75 »

davoodice2 wrote: Thu Nov 11, 2021 7:24 pm please Notice: We must store file before any changes we made. FileSaveAs or save cant do these
Sure they can, if you use them before any changes. Just like copying and writing the data before changes.
User avatar
davoodice2
Posts: 381
Joined: Tue Jun 15, 2021 1:14 pm

Re: Strange bug when saving file 13.5.2 (Solved. Not a bug)

Post by davoodice2 »

synthsin75 wrote: Thu Nov 11, 2021 8:06 pm
davoodice2 wrote: Thu Nov 11, 2021 7:24 pm please Notice: We must store file before any changes we made. FileSaveAs or save cant do these
Sure they can, if you use them before any changes. Just like copying and writing the data before changes.
Wes! I speak about incremental save! :?
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
synthsin75
Posts: 9985
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Strange bug when saving file 13.5.2 (Solved. Not a bug)

Post by synthsin75 »

davoodice2 wrote: Thu Nov 11, 2021 9:15 pm
synthsin75 wrote: Thu Nov 11, 2021 8:06 pm Sure they can, if you use them before any changes. Just like copying and writing the data before changes.
Wes! I speak about incremental save! :?
I am too. :D
Post Reply