Trying to find information on how to build a simple file version controll system - file

Im want to build a file system for non-tecks( dont care about old versions of the file so no merging or svn/git). The thougt is that a user should be able to download a file, in the same instance the file should be locked for other users. When the first user is done editing the, the file should then automaticaly upload to the server. When he closes the file, the lock should den be opend.
Is this even possible? Im thingking a sort of browser plugin, but I cant find anywone that has done the same thing. (besides microsoft, but who want to go down that road)

That would be: Sharepoint, Alfresco, (almost every WIKI), ...
Actually that is a basic feature of most document management systems. Even SVN has that already and IIRC you can set that up with mod_dav_svn without a line of code (considering configuration is not code).
Also the interesting question is, IMHO, not TheHappyCase where the described unit of work goes well but what about this*:
I Checkout 50 random documents you need
(get some popcorn and wait for your stresslevel to go up)
?????
I get bored and forget about it (everything still being checked out)
*: Points (1) and (2) may change order

Related

Is there any way to get exactly which part of file has been changed on Linux

I want to build file sync software. Is there any way to get exact file changes (or at least changes size) with kernel systems like I-notify or others?
EDIT:
I'm interested in the following scenario with I-notify:
When getting IN_MODIFY event on a file I want retrieve in some way changed lines of the file (some kind of a file diff format). Are there any linux kernel tools to achieve this?
Even if there were such a kernel feature, it would not work in practice. You see, most editors modify files by creating a copy, then renaming it over the original one. This way the user is assured of getting either the old contents or the new contents, never a mix between the two.
The only real option is to take snapshots of the file (at e.g. when file is closed when it was open for writing, or when the file is replaced with a new one), and compare the snapshots, to find which part was changed.
Comparing two versions of a file to see which part of it was changed is itself a difficult question, as it definitely depends on the file format. For source code, unified diffs work well, but for other types (including plain text files that are not line-oriented), it's not that simple.
Could you please refine your question? The inotify API on Linux does monitor such changes, and similar changes such as if a file was open, if a file inside a directory (or the directory itself) was moved and file deletions etc.
For more, see here:
(http://man7.org/linux/man-pages/man7/inotify.7.html)
EDIT:
I believe I misread the question the first time around, if I did, yes such programs exist and the inotify API is the primary one existing within the Linux kernels. See the above link for a comprehensive guide on the different functions it provides.

Lost code lines when Notepad++ crashed

I was working on a .js file this morning on Notepad++, as usual, when the program just crashed. So I ended it, and re-opened it to see that all my code lines in my .js file, had disappeared, and now all I have left is the file with a size of 0kb because there's nothing left in it. How the hell is that even possible ? It erased everything I typed and saved the file as if there's nothing in it.
Do you know a way to get my code back ? Or did something like this ever happened to someone ? :/ I'm kinda worried because there was a lot of work there and I don't feel like re-typing it all...
When that option is enabled (and it is by default), Notepad++ keeps a backup copy of files you edit.
You can find the backups in the directory %APPDATA%\Notepad++\backup under the format filename#datetime.
I lost four unsaved files when my Notepad++ crashed, I searched through net and found another way to retrieve unsaved files other than backup folder
C:\Users\{username}\AppData\Roaming\Notepad++\backup
Hope it can help others who face the same problem as me. You can try to locate the dump files at
C:\Users\{username}\AppData\Local\Temp\N++RECOV
There will be .dump file inside, this is where I found my unsaved files. You can open the dump file with Notepad++, and see your unsaved works.
This has happened to me a few times lately and I've found a few solutions that make it possible to recover the lost code.
For Windows 7 and probably other modern Windows versions:
Find the file in File Explorer. The size will be 0KB. Right click on it and then choose Properties from the context menu.
Choose the Previous Versions tab. There's a good chance you will find a fairly recent version saved during the latest Restore point. If it's a bit old, it's still probably better than the current 0KB.
Click the Restore button.
My personal optimal solution:
Since this happened to me a few times and the Windows Previous Version was not always up to date, I looked for a different solution that could always give me the latest, most up-to-date version before the 0KB crash.
I discovered that I already had the solution installed on my computer. I have a SugarSync account that always backs up my work files to the cloud. The great part of the service is that SugarSync always keeps the last 5 versions in the cloud, so while the current version will be 0KB, you can download the next to last version and update your file on your computer.
If you have some other backup program, you can check if that service also keeps different versions that you can recover.
I've used notepad++ without any backup for years. One day this happen to me, too.
Here is what I've found as possible solutions:
http://buffernow.com/notepad-plus-crash-recover-your-lost-file/
(similar to Indrajit answer) - not much help. I didn't find my file there.
I have recovered my file one week ago as per answer of Hvck
Same problem here. Same answers:
https://superuser.com/questions/390204/how-to-restore-a-previous-version-of-file-in-notepad
One lesson learned: Use the backup!
use a plugin:
http://www.ilovefreesoftware.com/12/windows/two-plugins-auto-save-files-notepad-auto-save-autosave2.html
use notepad++ backup
http://allinworld99.blogspot.ca/2015/01/notepad-backup-files.html
** UPDATE **
It happened to me again!!! Another way to recover my file: View source on my browser and resave the file to other location. If you are lucky enough to have the file loaded in your browser :) It worked for me for a css file and for a js file.
Comparing the files: what N++ backed-up and the file from browser and files are matching. OMG!
GO to Taskbar click and run %APPDATA%, click to Notepad++ click to backup.
Your files saved by filename.extensionname#year-month-date_time
I know it's too late to answer this, but maybe my answer will help others.
I've encountered the same problem recently. Then it became regular. I did not find a solution to the problem itself, plus it may be caused by many different reasons, so probably no universal solution exists.
However, there is a way to save your files while notepad++ is not closed. Even if the backups folder is empty.
First of all, do not close notepad++. Open a taskmanager, find the notepad++ process and locate the Dump or Create dump file option. Click it. This will create a whole memory dump of the process. This dump will contain the documents you had opened. However you may need to find this data, plus it may be in a different encoding. I guess it is in UTF8 most of the time, but I am not completely sure.
The dump file can be examined with simple programs like notepad++ itself or with a hex editor.
Notepad doesn't auto-save its open file so unfortunately you have lost your work.
On next time you can use Notepad++ it retrieves file automatically
Refer this link may it help you Notepad++ recovery
I tried all the above solutions but nothing was working for me.
But luckily I have opened files one day earlier in eclipse as well. Eclipse and all other IDEs maintain a cache of all the files. You can get the copy of the file from that cache. To get copy from the eclipse.
Right Click on the file Name
Go to Replace With - Previous from the Local History
This answer applies to more recent versions of NotePad++:
Go to the folder of the file, see if there is a subfolder called nppBackup. Recently I've found sometimes the backup wasn't created in %AppData%/Notepad++/backup but it always seems to get created here, with the following file name format [original file name][date stamp]_[time stamp].bak

Real remote editing without X-Forwarding, using Vim or the like

I'm currently working an a rather large web project which is written using C servlets ( utilizing GWAN Web server ). In the past I've used a couple of IDEs for my LAMP/PHP jobs, like Eclipse.
My problems with Eclipse are that you can either mirror the project locally, which isn't possible in this case as I'm working on a Mac (server does not run on OSX), or use the "remote" view, which would re-upload files when you save them.
In the later case, the file is only partly written while uploading, which makes this a no-go for a running web server, or the file could become corrupted if the connection was lost during uploading. Also, for changing some character, uploading the whole file seems rather inefficient to me.
So I was thinking:
Wouldn't it be possible to have the IDE open Vim per SSH and mirror my changes there, and then just :w (save) ? Or use some kind of diff-files for changes?
The first one would be preffered, as it has the added advantage of Vim .swp files, which makes it possible that others know when someone is already editing the file.
My current solution is using ssh+vim, but then I lose all the cool features I have with Eclipse and other more advanced IDEs.
Also, regarding X-Forwarding: The reason I don't like it is speed. It feels way slower than just editing locally, and takes up unneeded bandwidth, when all I want to do is basically "text editing".
P.S.: I couldn't find any more appropriate tags for the question, especially no "remote" tag, but if you know any, feel free to add them. Also, if there is another similar question, feel free to point it out - I couldn't find any.
Thank you very much.
If you're concerned about having to transmit the entire file for minor changes, the only solution that comes to my mind is running (either continuously, or on demand) an rsync job that mirrors the remote site to your local system (and back). The rsync protocol just transmits the delta information. According to Are rsync operations atomic at file level?, the change is atomic.
Another possibility: run everything in a virtual machine on your Mac. The server and the IDE/text editor are both on the same virtual machine so you don't have to fear network issues.
Because the source code on the virtual machine is under some kind of VCS the classic code → test → commit process is trivial (at least theoretically).

How to create an undeletable file in Delphi

[the following is a rephrase of my previous question, which was deemed ambiguous].
I'm digging into creating a basic licensing mechanism for a demo application. What I have in mind goes like that: the application creates an empty "license file" called, say "0b1xa487x.ini" upon the first run, then expires 30 days after it has been first executed and can't be run anymore as long as that specific file is present on the system.
What I'm looking for is a method to protect that specific file in a way to deter deletion. Since it will be a blank file, devoid of any content, I wouldn't mind it to be corrupt, have corrupt headers, invalid date, whatever it takes to stay undeletable.
I've seen a similar approach somewhere based on file attributes (the file had the HX attributes set in place); however, the attribute approach lead me nowhere, as I can't find any documented feature on the existence of a file attribute X.
I also know that there are other approaches including rootkit drivers and system services launched as system user, but this particular one seems to fit best in this scenario. Again, I outline that the file's contents may as well be inaccessible, I'm not planning to use the approach in running any kind of malware from the file, as I've been accused below :)
Corrupt suggests not conforming to some standard. There are no standards for blank files.
Thanks everybody for your suggestions. I found a way to render my file inaccessible, namely by using fortunate combination of file permissions. The downside is that these things don't work on non-NTFS partitions. The good thing is that I can always clean up after my application by simply removing these permissions programatically and deleting everything afterwards.
Regarding your last answer to Henk, I believe it is more easier to create a service, start it automatically with the OS, and open the file in the fmShareExclusive by using a TFileStream.
But, you can not force the kernel of the OS, or an antivirus to make your file 'undeletable'.
Best regards,
Radu

Why doesn't checking out in TFS 2010 give me write permissions? It causes an exception in my project at the target of invocation

I just moved my code from subversion to TFS.
When I get latest version, I understand that I can't get write permissions.
However, when I check out and choose the option to take the exclusive lock, a check mark appears next to my files and I am able to edit them.
When I look in Windows explorer, however, some files are still marked "read only."
This becomes a problem when I try and run my application. For some reason, not having write permissions to everything gives me an exception at the target of invocation message (its a wpf project).
When I run the files out of version control, everything is fine. When I run the version under TFS, I get that exception--even when I've exclusively checked the files out.
Any idea what is going on here?
Sounds like quite a bit of confusion here. So i have a number of questions:
Did you specifically check out the files that are still marked "read only"? Or did you just check out other files which may be related to the ones marked "read only".
Did you use the Source Control window or the Solution Explorer when performing the checkout command? Did you select specific files or just the top level project file?
Are the files actually part of the project? or are they simply in the same folder but still under source control?
What exact error message are you getting?
What files are the problem? In other words have you checked in the compiled binaries from the BIN or OBJ folders?
TFS terminology is a little different than SVN.
"Get" represents an update in SVN terms.
"Checkin" commits your changes and both "Checkin" and "Checkout" are responsible for managing file locks.
"Checkin" releases the locks.
"Checkout" requests the locks.
There are 3 types of locking you can use or none at all. I would opt for using None as it's likely to cause the least issues, many of which can be resolved during a merge and a little bit of communication.

Resources